/ Gists / MySQL delete dupes, keep newer
On gists

MySQL delete dupes, keep newer

MySql

MySQL delete dupes, keep newer.s Raw #

DELETE mytable
    FROM mytable
    INNER JOIN (
            SELECT max(id) AS lastId, someColumnWithDupes
            FROM mytable
            GROUP BY someColumnWithDupes
            HAVING count(*) > 1
            ) duplic ON duplic.someColumnWithDupes = mytable.someColumnWithDupes
    WHERE mytable.id < duplic.lastId;