[Err] 1093 - You can't specify target table 's' for update in FROM clause
execute SQL
DELETE from book WHERE id IN( SELECT id FROM ( SELECT id,name FROM book WHERE name IN( SELECT name FROM book GROUP BY name HAVING count(name) > 1 ) ) t WHERE id NOT IN ( SELECT id FROM book GROUP BY name HAVING count(name) > 1 ) );
An error occurred:
[Err] 1093 - You can't specify target table 's' for update in FROM clause
I get this error when executing the SQL statement. The reason is that when the table and data are updated, it is queried again, and the queried data has been updated with conditions
Solution: Query the data to be deleted as a third-party table, and then delete it.
DELETE book from book , ( SELECT id FROM ( SELECT id FROM book WHERE name IN(SELECT name FROM book GROUP BY name HAVING count(name) > 1) ) t WHERE id NOT IN (SELECT id FROM book GROUP BY name HAVING count(name) > 1) ) as a WHERE book.id = a.id;