I got an "error '#1093 - You can't specify target table 't1' for update in FROM clause" with this code:
UPDATE `table1` t1 SET t1.name = 'abc'
WHERE t1.id = 165 AND NOT EXISTS (
SELECT t2.id FROM `table1` t2 WHERE t2.id != 165 AND t2.name = 'abc'
)
But there is no problem with the code:
UPDATE `table1` t1 SET t1.name = 'abc'
WHERE t1.id = 165 AND NOT EXISTS (
SELECT t2.id FROM `table2` t2 WHERE t2.id != 165 AND t2.name = 'abc'
)
What did I go wrong?