mrkeck Sharing the Love

9Oct/150

DELETE From Same MySQL Table

From http://stackoverflow.com/questions/4685173/delete-all-duplicate-rows-except-for-one-in-mysql

Quoted in case the page goes away one day

DELETE FROM NAMES
WHERE id NOT IN (SELECT *
FROM (SELECT MIN(n.id)
FROM NAMES n
GROUP BY n.name) x)

I guess you have to sneak it past by putting inside another subquery. Worked!

Filed under: mySQL No Comments