Mysql函数->TRIM(去掉首尾空格、任意字符)

      发布在:数据库技术      评论:0 条评论

TRIM

语法

TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str)

序号函数                                                 函数结果      备注
1trim(' test ')'test'删除字符串前后空格
2trim(both from ' test ')'test''both'参数表示同时去除字符串前后所指定的内容(默认情况下删除空格)
3trim(trailing from ' test ')' test''trailing'参数表示删除字符串尾部空格
4trim(leading from ' test ')'test ''leading'参数表示删除字符串头部空格
5trim('x' from 'xxxtestxxx')'test'删除字符串前后的字符'x' 
6trim(both 'x' from 'xxxtestxxx')'test'删除字符串前后的字符'x'
7trim(trailing 'xy' from  'xyxyxtestxxyxy')'xyxyxtestx'删除字符串尾部的字符串'xy'
8trim(leading 'xy' from 'xyxyxtestxxyxy')'xtestxxyxy'删除字符串头部的字符串'xy'
9trim(leading 'xy' from trim(trailing 'xy' from  'xyxtestxxy'))'xtestx'删除字符串头尾的字符'xy'

LTRIM / RTRIM 

去掉字符串左/右边的空格

序号函数                        函数结果    备注                              
1ltrim(' test ')'test '去掉字符串左边的空格
2rtrim(' test ')' test'去掉字符串右边的空格




作者:小念


相关文章
热门推荐