mysql查询一张表的同时不能再对表进行更改,会报1093错误,MySQL can’t specify target table for update in FROM clause
解决:将查询出来的结果作为一张中间表重新查询,这时候在对原先的表进行更改就可以了。
常见update操作手册:
1、update 时,更新的表不能在set和where中用于子查询;
2、update 时,可以对多个表进行更新(sqlserver不行);
如:update ta a,tb b set a.Bid=b.id ,b.Aid=a.id;
3、update 后面可以做任意的查询,这个作用等同于from;