DELETE FROM yourTable WHERE id NOT IN ( SELECT MIN (id) FROM yourTable GROUP BY anotherColumn) |
If you want to remove older rows, use the following:
DELETE FROM yourTable WHERE id NOT IN ( SELECT MAX (id) FROM yourTable GROUP BY anotherColumn) |
Leave a Reply