只需一条简单sql语句

DELETE FROM ceshi WHERE id NOT IN (SELECT id from ( SELECT min(id) AS id FROM ceshi GROUP BY `name`,class)a)