You can’t specify target table ‘car’ for update in from clause

Error Code: 1093 occurs when the following SQL statement is executed:

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 this 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);

Read More: