Let’s say I want to first select rows which have download_link the same. Then, I want to keep the one that has lowest primary id, and throw away the rest.
Is there an easy SQL statement for this? Would this work?
delete from mytable
where id not in
(select min(id)
from mytable
group by download_link);
You don’t need temporary tables or subqueries. You can do it with a simple join:
That is, “delete every row for which there is another row with the same link and a lower ID”.