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'trim函数用于删除空格
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 '

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。

发表评论