trim()函数mysql中的强⼤字符串过滤函数mysql中功能强⼤的trim()函数.
去除两边空格:
mysql>select trim(' hello world ');
+-----------------------+
| trim(' hello world ') |
+-----------------------+
| hello world |
+-----------------------+
1 row in set
去除左边空格:
select ltrim(' hello world ');
去除右边空格:
select rtrim(' hello world ');
trim函数还可以过滤指定字符串:
去除两边逗号:
mysql>SELECT TRIM(BOTH ','FROM',a,b,c,');
+-------------------------------+
| TRIM(BOTH ','FROM',a,b,c,') |
+-------------------------------+
| a,b,c |
+-------------------------------+
1 row in set
去除左边逗号:
mysql>SELECT TRIM(LEADING ','FROM',,,abc');
+---------------------------------+
| TRIM(LEADING ','FROM',,,abc') |
+---------------------------------+
| abc |
+---------------------------------+
1 row in set
去除右边逗号:
mysql>SELECT TRIM(TRAILING ','FROM',,,abc,,,,,');trim函数用于删除空格
+---------------------------------------+
| TRIM(TRAILING ','FROM',,,abc,,,,,') |
+---------------------------------------+
| ,,,abc |
+---------------------------------------+
1 row in set
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论