Mysql: [HY000][1093] You can't specify target table 'dupes' for update in FROM clause
错误原因
在同一语句中。不能先SELECT出同一表的某些值,在Update这个表
实例
错误实例
DELETE
FROM dupes
WHERE id NOT IN (SELECT MIN(id)
FROM dupes
GROUP BY name)
正确实例
DELETE
FROM dupes
WHERE id NOT IN (SELECT * FROM (SELECT MIN(id) FROM dupes GROUP BY name) z);
学以致用,知行合一