首页 - 电子商务 - mysql与正则表达式  
  关于我们  
网站建设
网站推广
电子商务
联系我们

mysql与正则表达式

2008-1-4 14:49:53

将comment表中的author_url包含www.sohu.com的记录,其中的sohu替换为sina,一个语句搞定~

update comment set author_url=REPLACE(author_url, 'sohu', 'sina') where author_url REGEXP "www.sohu.com";

带IF判断的复杂替换

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;
本文转摘自『IT学习者』http://www.itlearner.com/article/2007/3917.shtml

责任编辑:
相关文章
 
联系电话:021-51872701 51302668 51302669 上海旭强信息科技有限公司 版权所有