The reason your UPDATE
is failing is because you're referencing the same table that is targeted for UPDATE
, which causes a conflict, as changes may occur in the data returned from the nested subquery in the process of updating the outer table, thus producing unpredictable results.
As others have already pointed out in the comments, the Nested Select in the WHERE
clause also happens not to be doing anything, because it's selecting all IDs from the same table.
In addition to the above noted problems, it's never advisable to use a subquery with MySQL, as they perform terribly (as a they are executed for each row in the outer query, potentially millions of times).
Assuming you need a where clause at all, you would do better to rewrite the above as a JOIN, (and potentially as a derived table) as necessary.