方法一
DELETE FROM A WHERE `name` in ( SELECT a.name FROM( SELECT name FROM A a GROUP BY name HAVING COUNT(`name`)>1 )a) AND id NOT IN( SELECT b.mid FROM (SELECT MAX(`id`) AS mid FROM A b GROUP BY `name` HAVING COUNT(`name`)>1)b) ;
方法二
DELETE FROM A WHERE id NOT in ( SELECT a.mid FROM ( SELECT MAX(id) as mid FROM A a GROUP BY name)a );