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