TRIM函数去掉指定字符
2023-05-05 09:57:33 阅读次数:273
字符
- mysql> select * from ss;
- +----+--------+
- | id | sid |
- +----+--------+
- | 1 | 001230 |
- | 4 | 010300 |
- | 2 | 012300 |
- | 3 | 123000 |
- +----+--------+
- 4 rows in set (0.09 sec)
-
- mysql> SELECT id,TRIM(LEADING '0' FROM sid) AS sid FROM ss;
- +----+--------+
- | id | sid |
- +----+--------+
- | 1 | 1230 |
- | 4 | 10300 |
- | 2 | 12300 |
- | 3 | 123000 |
- +----+--------+
- 4 rows in set (0.03 sec)
-
- mysql> SELECT id,TRIM(TRAILING '0' FROM sid) AS sid FROM ss;
- +----+-------+
- | id | sid |
- +----+-------+
- | 1 | 00123 |
- | 4 | 0103 |
- | 2 | 0123 |
- | 3 | 123 |
- +----+-------+
- 4 rows in set (0.03 sec)
-
- mysql> SELECT id,TRIM(BOTH '0' FROM sid) AS sid FROM ss;
- +----+------+
- | id | sid |
- +----+------+
- | 1 | 123 |
- | 4 | 103 |
- | 2 | 123 |
- | 3 | 123 |
- +----+------+
- 4 rows in set (0.02 sec)
-
版权声明:本文内容来自第三方投稿或授权转载,原文地址:https://blog.51cto.com/hcymysql/1065631,作者:hcymysql,版权归原作者所有。本网站转在其作品的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如因作品内容、版权等问题需要同本网站联系,请发邮件至ctyunbbs@chinatelecom.cn沟通。
上一篇:Mybatis对象关联数据库表【一对多关联AND一对一关联】
下一篇:Linux MySQL数据库的备份