DELETE tFROM test tINNER JOIN ( SELECT min(id) AS id, `name`, age FROM test GROUP BY `name`, age HAVING count(*) > 1) AS t2 ON t.`name` = t2.`name`AND t.age = t2.age AND t.id > t2.id;