首页域名资讯 正文

Mysql的replace函数替换字符串

2024-12-26 5 0条评论

要把数据库中某个列的所有值中含有”test.trustauth.cn”的字符更换成”www.trustauth.cn”,方法有几种,如shell脚本,但是这样效率非常低,但Mysql中有replace函数很容易实现替换。

replace(str,from_str,to_str)

在字符串 str 中所有出现的字符串 from_str 均被to_str替换,然后返回这个字符串

如你要将表wp_posts里面的guid字段的http://test.trustauth.cn/…替换为http://www.trustauth.cn/…:

update wp_posts set guid=replace(guid,’http://test.trustauth.cn/’,’http://www.trustauth.cn/’);

文章版权及转载声明

本文作者:亿网 网址:https://www.edns.com/ask/post/150149.html 发布于 2024-12-26
文章转载或复制请以超链接形式并注明出处。