亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

  免費(fèi)注冊(cè) 查看新帖 |

Chinaunix

  平臺(tái) 論壇 博客 文庫(kù)
12下一頁(yè)
最近訪問(wèn)板塊 發(fā)新帖
查看: 9912 | 回復(fù): 10
打印 上一主題 下一主題

mysql中如何識(shí)別記錄中的tab鍵,回車鍵? [復(fù)制鏈接]

論壇徽章:
0
跳轉(zhuǎn)到指定樓層
1 [收藏(0)] [報(bào)告]
發(fā)表于 2009-03-16 16:28 |只看該作者 |倒序?yàn)g覽
mysql中如何識(shí)別記錄中的tab鍵,回車鍵?

比如下列code a到where之間,應(yīng)該就有個(gè)tab鍵或回車鍵:
+-------------------------------------------------------+
| trim(sql_text)                                                |
+-------------------------------------------------------+
| select count(*) from code a               where |
| status <> 'D'                                                 |
+-------------------------------------------------------+

論壇徽章:
1
白銀圣斗士
日期:2015-11-23 08:33:04
2 [報(bào)告]
發(fā)表于 2009-03-16 16:36 |只看該作者

回復(fù) #1 xzh2000 的帖子

好像不能,沒(méi)有這樣的函數(shù)。

你的目的是啥?

論壇徽章:
0
3 [報(bào)告]
發(fā)表于 2009-03-16 17:00 |只看該作者
原帖由 楓影誰(shuí)用了 于 2009-3-16 16:36 發(fā)表
好像不能,沒(méi)有這樣的函數(shù)。

你的目的是啥?


我主要是想把SQL中多余的空格與控制符去掉...

論壇徽章:
0
4 [報(bào)告]
發(fā)表于 2009-03-16 17:05 |只看該作者
偶已經(jīng)搞定了:

delimiter //
drop function if exists sql_clearspace//

create function sql_clearspace(v_sql varchar(4000))
  returns varchar(4000)
begin
  declare v_tmps varchar(4000) default '';
  declare v_last varchar(2) default '';
  declare v_curr varchar(2) default '';
  declare v_num int default 0;
  declare v_max int default 0;
  
  set v_max = length(v_sql);
  while v_num <> v_max do
    set v_num = v_num + 1;
    set v_curr = substr(v_sql, v_num, 1);
   
    if (v_curr = char(9) or v_curr = char(10)) then
      set v_curr = char(32);
    end if;
   
    if (v_curr <> char(32) and (v_last is null or v_last <> char(32))) then
      set v_tmps = concat(v_tmps, v_curr);
      set v_last = v_curr;
    elseif (v_last <> char(32) and v_curr = char(32)) then
      set v_tmps = concat(v_tmps, v_curr);
      set v_last = v_curr;
    elseif (v_last = char(32) and v_curr <> char(32)) then
      set v_tmps = concat(v_tmps, v_curr);
      set v_last = v_curr;
    end if;
  end while;
  
  return v_tmps;
end//

delimiter ;


mysql> select sql_clearspace('select count(*) from code a                     where status <> 1');
+-------------------------------------------------------------------------------------+
| sql_clearspace('select count(*) from code a                     where status <> 1') |
+-------------------------------------------------------------------------------------+
| select count(*) from code a where status <> 1                                       |
+-------------------------------------------------------------------------------------+
1 row in set (0.01 sec)

論壇徽章:
1
白銀圣斗士
日期:2015-11-23 08:33:04
5 [報(bào)告]
發(fā)表于 2009-03-16 17:15 |只看該作者
mysql> select replace("select count(*) from code a               where",'  ','');  
+--------------------------------------------------------------------+
| replace("select count(*) from code a               where",'  ','') |
+--------------------------------------------------------------------+
| select count(*) from code a where                                  |
+--------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql>


可以這樣。。。

論壇徽章:
0
6 [報(bào)告]
發(fā)表于 2009-03-16 17:20 |只看該作者
原帖由 楓影誰(shuí)用了 于 2009-3-16 17:15 發(fā)表
mysql> select replace("select count(*) from code a               where",'  ','');  
+--------------------------------------------------------------------+
| replace("select count(*) from code a ...


謝謝...

論壇徽章:
0
7 [報(bào)告]
發(fā)表于 2009-03-16 17:23 |只看該作者
原帖由 楓影誰(shuí)用了 于 2009-3-16 17:15 發(fā)表
mysql> select replace("select count(*) from code a               where",'  ','');  
+--------------------------------------------------------------------+
| replace("select count(*) from code a ...


測(cè)試了一下,發(fā)現(xiàn)這個(gè)還沒(méi)有考慮換行符:
mysql> select replace("select count(*)   from code a               
    ">       where status <> 1",'  ','');
+-----------------------------------------------------------------------------------------+
| replace("select count(*)   from code a               
      where status <> 1",'  ','') |
+-----------------------------------------------------------------------------------------+
| select count(*) from code a
where status <> 1                                          |
+-----------------------------------------------------------------------------------------+
1 row in set (0.00 sec)

論壇徽章:
1
白銀圣斗士
日期:2015-11-23 08:33:04
8 [報(bào)告]
發(fā)表于 2009-03-16 17:59 |只看該作者

回復(fù) #7 xzh2000 的帖子

mysql> select replace("select count(*) from code a               where                                            dsdsds                                                                                                            ",'\n','');
+----------------------------------------------------------------------------+
| replace("select count(*) from code a               where
dsdsds
",'\n','') |
+----------------------------------------------------------------------------+
| select count(*) from code a               wheredsdsds                      |
+----------------------------------------------------------------------------+
1 row in set (0.00 sec)

mysql>

論壇徽章:
1
白銀圣斗士
日期:2015-11-23 08:33:04
9 [報(bào)告]
發(fā)表于 2009-03-16 18:06 |只看該作者
mysql> select @a;
+------------------------------------------------------------+
| @a                                                         |
+------------------------------------------------------------+
| select count(*) from code a               where
abc  <> 0 |
+------------------------------------------------------------+
1 row in set (0.00 sec)

mysql> select replace(replace(@a,'n',''),'  ','');
+-------------------------------------------+
| replace(replace(@a,'n',''),'  ','')      |
+-------------------------------------------+
| select count(*) from code a where abc<> 0 |
+-------------------------------------------+
1 row in set (0.00 sec)

mysql>


這個(gè)結(jié)果是你要的吧!

論壇徽章:
0
10 [報(bào)告]
發(fā)表于 2009-03-16 18:09 |只看該作者
原帖由 楓影誰(shuí)用了 于 2009-3-16 18:06 發(fā)表
mysql> select @a;
+------------------------------------------------------------+
| @a                                                         |
+----------------------------------------------- ...


差不多了,謝謝...
您需要登錄后才可以回帖 登錄 | 注冊(cè)

本版積分規(guī)則 發(fā)表回復(fù)

  

北京盛拓優(yōu)訊信息技術(shù)有限公司. 版權(quán)所有 京ICP備16024965號(hào)-6 北京市公安局海淀分局網(wǎng)監(jiān)中心備案編號(hào):11010802020122 niuxiaotong@pcpop.com 17352615567
未成年舉報(bào)專區(qū)
中國(guó)互聯(lián)網(wǎng)協(xié)會(huì)會(huì)員  聯(lián)系我們:huangweiwei@itpub.net
感謝所有關(guān)心和支持過(guò)ChinaUnix的朋友們 轉(zhuǎn)載本站內(nèi)容請(qǐng)注明原作者名及出處

清除 Cookies - ChinaUnix - Archiver - WAP - TOP