Reputation: 575
update table1
set isDeleted = 1
where isDeleted = 0
and mId in (select id from table1 where isDeleted = 1 );
Error Code: 1093. You can't specify target table 'table1' for update in FROM clause
Upvotes: 1
Views: 41
Reputation: 780974
Use a join:
UPDATE table1 t1
JOIN table1 t2 ON t1.mId = t2.id
SET t1.isDeleted = 1
WHERE t1.isDeleted = 0
AND t2.isDeleted = 1
Upvotes: 2