MySQL中如何使用REPLACE()函数

REPLACE()

REPLACE(str,from_str,to_str)函数用于将字符串 str 中所有的 from_str 替换为 to_str,返回替换后的字符串。例如:

SELECT REPLACE('MySQL字符串函数', '字符串', '日期') AS str1,
       REPLACE('MySQL字符串函数', '字符串', '') AS str2;
str1        |str2     |
------------+---------+
MySQL日期函数|MySQL函数|

另外,INSERT(str,pos,len,newstr)函数用于在字符串 str 的指定位置 pos 之后插入子串 newstr,替换随后的 len 个字符。例如:

SELECT INSERT('MySQL字符串函数', 6, 3, '日期') AS str;
str         |
------------+
MySQL日期函数|

以上就是MySQL中如何使用REPLACE()函数的详细内容,更多请关注www.sxiaw.com其它相关文章!