您的位置:首页 > 数据库 > MySQL

mysql中的替换语句

2007-02-08 16:06 330 查看
如下:

update users_settings set `ConfigValue` = replace(configvalue,' fromstr' ,'tostr') where `ConfigName`='accesslist'

将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;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: