You can't specify target table 'tabName' for update in FROM clause
mysql update 错误:#1093 - You can't specify target table content for update in FRO
在mysql查询中使用以下语句:
update table1 set '字段1' = 'value1' where (select子句含table1字段)
会报错:
#1093 - You can't specify target table content for update in FROM clause
原因是不能根据select一个表得到的条件,来同时update这个表。
解决方案:
create table tmp as (select子句)
update table1 set '字段1' = 'value1' where XXX in(select xxxfrom tmp);
drop table tmp;