Mysql 的trim() 函式
Mysql 的trim() 函式
mysql中的去除左空格函式:
LTRIM(str)
Returns the string str with leading space characters removed.
以下是程式碼片段:
mysql> SELECT LTRIM(' barbar');
-> 'barbar'
This function is multi-byte safe.
mysql中的去除右空格函式:
RTRIM(str)
Returns the string str with trailing space characters removed.
以下是程式碼片段:
mysql> SELECT RTRIM('barbar ');
-> 'barbar'
This function is multi-byte safe.
trim函式可以過濾指定的字串:
完整格式:TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str)
簡化格式:TRIM([remstr FROM] str)
Returns the string str with all remstr prefixes or suffixes removed. If none of the specifiers BOTH, LEADING,
or TRAILING is given, BOTH is assumed. remstr is optional and, if not specified, spaces are removed.
以下是程式碼片段:
mysql> SELECT TRIM(' bar '); //預設刪除前後空格
-> 'bar'
mysql> SELECT TRIM(LEADING ',' FROM ',,barxxx'); //刪除指定首字元 如',‘
-> 'barxxx'
mysql> SELECT TRIM(BOTH ',' FROM ',,bar,,,'); //刪除指定首尾字元
-> 'bar'
mysql> SELECT TRIM(TRAILING ',' FROM 'barxxyz,,');
-> 'barxxyz'
mysql> UPDATE table SET `field`=TRIM(TRAILING ',' FROM `FIELD`) WHERE WHERE `FIELD` LIKE '%,';
This function is multi-byte safe.
替換資料庫中欄位的最後一個分頁符
程式碼如下:
UPDATE [!db.pre!]ecms_news_data_1 SET `newstext`=TRIM(TRAILING '[!--empirenews.page--]' FROM `newstext`) WHERE id=585;
SELECT TRIM(TRAILING '[!--empirenews.page--]' FROM `newstext`) AS newstex FROM [!db.pre!]ecms_news_data_1 WHERE id=585;
mysql中的去除左空格函式:
LTRIM(str)
Returns the string str with leading space characters removed.
以下是程式碼片段:
mysql> SELECT LTRIM(' barbar');
-> 'barbar'
This function is multi-byte safe.
mysql中的去除右空格函式:
RTRIM(str)
Returns the string str with trailing space characters removed.
以下是程式碼片段:
mysql> SELECT RTRIM('barbar ');
-> 'barbar'
This function is multi-byte safe.
trim函式可以過濾指定的字串:
完整格式:TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str)
簡化格式:TRIM([remstr FROM] str)
Returns the string str with all remstr prefixes or suffixes removed. If none of the specifiers BOTH, LEADING,
or TRAILING is given, BOTH is assumed. remstr is optional and, if not specified, spaces are removed.
以下是程式碼片段:
mysql> SELECT TRIM(' bar '); //預設刪除前後空格
-> 'bar'
mysql> SELECT TRIM(LEADING ',' FROM ',,barxxx'); //刪除指定首字元 如',‘
-> 'barxxx'
mysql> SELECT TRIM(BOTH ',' FROM ',,bar,,,'); //刪除指定首尾字元
-> 'bar'
mysql> SELECT TRIM(TRAILING ',' FROM 'barxxyz,,');
-> 'barxxyz'
mysql> UPDATE table SET `field`=TRIM(TRAILING ',' FROM `FIELD`) WHERE WHERE `FIELD` LIKE '%,';
This function is multi-byte safe.
替換資料庫中欄位的最後一個分頁符
程式碼如下:
UPDATE [!db.pre!]ecms_news_data_1 SET `newstext`=TRIM(TRAILING '[!--empirenews.page--]' FROM `newstext`) WHERE id=585;
SELECT TRIM(TRAILING '[!--empirenews.page--]' FROM `newstext`) AS newstex FROM [!db.pre!]ecms_news_data_1 WHERE id=585;
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29500582/viewspace-1365194/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- trim函式函式
- 【TRIM】TRIM函式“去空格” 功能之外的洞天函式
- Trim() 函式的介紹函式
- javascript中的trim函式JavaScript函式
- PHP trim()函式 用法示例PHP函式
- js編寫trim()函式JS函式
- 【函式】Oracle TRIM函式語法介紹函式Oracle
- Trim() 函式的介紹【Blog 搬家】函式
- js中trim函式的簡單實現JS函式
- javascript trim()函式用法簡單介紹JavaScript函式
- PHP4使用者手冊:函式->trim (轉)PHP函式
- MySQL常用的字元函式:length,cancat,substr(substring),instr,trim,upper,lower,lpad,rpad,replaceMySql字元函式
- MYSQL的字串函式MySql字串函式
- mysql函式MySql函式
- Mysql 常用函式(15)- upper 函式MySql函式
- 【Mysql 學習】日期函式函式MySql函式
- MySQL的concat函式MySql函式
- MySQL 常用函式MySql函式
- MySQL 常用函式。MySql函式
- MySQL函式(一)MySql函式
- MySQL常用函式MySql函式
- mysql拼接函式MySql函式
- MySQL函式大全(字串函式,數學函式,日期函式,系統級函式,聚合函式)MySql函式字串
- MySQL函式學習(一)-----字串函式MySql函式字串
- MySQL函式-條件判斷函式MySql函式
- MySQL的GET_LOCK函式MySql函式
- mysql 常用的九類函式MySql函式
- mysql中的時間函式MySql函式
- (4)mysql 中的常用函式MySql函式
- mysql中replace函式的用法MySql函式
- MySQL concat函式的使用MySql函式
- Mysql 常用函式(1)- 常用函式彙總MySql函式
- mysql FIND_IN_SET函式、INSTR函式MySql函式
- MySQL 內建函式MySql函式
- Mysql視窗函式MySql函式
- Mysql內建函式MySql函式
- 7mysql函式MySql函式
- MySQL時間函式MySql函式