MySQL正则表达式替换,字符替换方法

by 尘缘 on 八月 16th, 2008 // Filed Under → MySQL

两句SQL,都是字符替换,比较好用。

update comment set url=IF(url REGEXP 'test.yahoo.com.cn',REPLACE(url,'www1.sohu.com','www.sina.com'),REPLACE(url,'www2.yahoo.com','www.sina.com')) where 1=1;
update comment set author_url=REPLACE(author_url,'sohu','sina') where author_url REGEXP 'www.sohu.com';

你可以任意转摘“MySQL正则表达式替换,字符替换方法”,但请保留本文出处和版权信息。
作者:尘缘,QQ:130775,来源:http://www.4wei.cn/archives/176

有 2 条评论啦

Posted on 2011年03月30号 at 11:15:01

欢乐网 :

你这玩意 不支持正则表达式,其实和直接用replace 直接替换差不到哪儿去了 ,汗~~~ 还写那么复杂

replace 函数能实现这样的功能吗?

Posted on 2011年04月15号 at 22:01:56

wildwindfeng :

使用REPLACE来替换最后等于没用。哎



走过路过,千万不要飞过,那是鸟人: