mysql清除数据库中字符串空格方法 |
您所在的位置:网站首页 › 如何删除数字中的空格 › mysql清除数据库中字符串空格方法 |
在mysql清除字符串空格有两个常用的使用方法一种是利用trim函数另一种是直接replace字符替换函数进行清除(1)mysql replace 函数 语法:replace(object,search,replace) 意思:把object中出现search的全部替换为replace 案例: 代码如下 复制代码1 update `news` set `content`=replace(`content`,' ',''); //清除news表中content字段中的空格 (2)mysql trim 函数 完整格式:TRIM([{BOTH | LEADING | TRAILING} [remstr] FROM] str) 简化格式:TRIM([remstr FROM] str) 以下举例说明: 代码如下 复制代码1 mysql> SELECT TRIM(' phpernote '); 2 -> 'phpernote' 1 mysql> SELECT TRIM(LEADING 'x' FROM 'xxxphpernotexxx'); 2 -> 'phpernotexxx' 1 mysql> SELECT TRIM(BOTH 'x' FROM 'xxxphpernotexxx'); 2 -> 'phpernote' 1 mysql> SELECT TRIM(TRAILING 'xyz' FROM 'phpernotexxyz'); 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. --本篇文章转自:http://www.111cn.net/database/mysql/46555.htm |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |