mysql的update的一些特点
1、更新的表不能在set和where中子查询;
2、可以对多个表进行更新(sqlserver不行);
如:update ta a,tb b set a.Bid=b.id ,b.Aid=a.id;
3、update 后面可以做任意的查询,这个作用等同于from;
写法:将子查询提到前面和查询的表一起类似关联查询的写法。
update 子查询实例:
#将表article 的字段content 里面包含 /public/ 的内容都替换为 / 实际就是去掉 public/ UPDATE article a,(select id from article where content like '%/public/%') b set a.content = REPLACE(a.content,'/public/','/') where a.id in b.id;