MYSQL ERRORCODE
Error Code 1093
update car set tag = 1 where id in (select id from car where brand_id=182 and tag=0);
Error Code: 1093. You can’t specify target table ‘O’ for update in FROM clause 0.000 sec
解决方法
出现错误的原因是因为修改的表和查询的表是同一个表,MySQL是不允许这样做的,我们可以通过中间再查询一次来解决:
update car set tag = 1 where id in (select id from (select id from car where brand_id=182 and tag=0) As temp);
作者:回归心灵
来源:优快云
原文:https://blog.youkuaiyun.com/u010657094/article/details/64439486