DELETE FROM table WHERE id IN ( SELECT src.id FROM ( SELECT t1.id FROM table t1 WHERE ( t1.col1, t1.col2, t1.col3, t1.col4, t1.col5 ) IN ( SELECT col1, col2, col3, col4, col5 FROM table GROUP BY col1, col2, col3, col4, col5 HAVING count(*) > 1 ) AND t1.id NOT IN ( SELECT MAX(id) FROM table GROUP BY col1, col2, col3, col4, col5 HAVING count(*) > 1 ) ) src );