Tag Archives: Error Code: 1093. You can’t specify target table ‘car’ for update in …

[Solved] MySQL Error Code: 1093. You can’t specify target table ‘car’ for update in …

Error code: 1093. You can’t specify target table ‘car’ for update in from clause

 

Error code: 1093 error occurs when executing the following SQL statement:

update car set tag = 1 where id in (select id from car where brand_id=182 and tag=0);

 

The reason for the error is that the modified table and the queried table are the same table, which is not allowed in MySQL. We can solve the problem by querying again in the middle

update car set tag = 1 where id in (select id from (select id from car where brand_id=182 and tag=0) As temp);