I need to remove rows where there is a duplicate link
column from a table. I'm trying to run:
delete from resultitem
where id in (select r.id
from resultitem r
group by r.link
having count(r.id) >1);
But getting an error:
ERROR 1093 (HY000): You can't specify target table 'resultitem' for update in FROM clause
Is this possible to remove rows by subquery in MySQL without a temporary table? Please advise.
Try this one...
This should delete all but the lowest
id
perlink
:Live example at SQL Fiddle.
To remove all duplicate links, leaving none of the duplicates behind, remove the
and ri1.id > ri2.id
.