Im trying to apply this solution to my data in table in MySQL DB which has duplicates. And I get such error:
SQL Error [1093] [HY000]: You can't specify target table 'NAME' for update in FROM clause
DELETE NAME FROM NAME
WHERE NAME.id NOT IN
(SELECT MIN(id)
FROM NAME GROUP BY col1, col2)
Also tried too assign aliases - but without success.
What reason of this error here?
It generally points that SQL script can produce cyclic process, but here I actually dont see any relevant to this - It is obvious that two selections for DELETE
and for SELECT
is detached - engine must do SELECT
once firstly and then use it in WHERE
conditions for DELETE
.
So - why this error happens and how can I actually deduplicate my table? =)