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';

发表评论

评论列表(3)

  • 匿名

    2017.1.11 18:01

    差评。

    回复
  • wildwindfeng

    2011.4.15 22:04

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

    回复
  • 欢乐网

    2011.3.30 11:03

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

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

    回复