PS:下面是转过来的,用于记录下,这个不是正则的初衷,只是用了REGEXP而已,正则的更灵活更方便
将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;
全文:https://www.jb51.net/article/8588.htm
清空MySQL表,如何使ID重新从1自增???
truncate语句,是清空表中的内容,包括自增主键的信息。truncate表后,表的主键就会重新从1开始。
语法:
TRUNCATE TABLE table1
全文:https://zhidao.baidu.com/question/510764281.html