首先是sql查询重复数据语法
SELECT * FROM [表名] WHERE [字段] IN ( SELECT [字段] FROM [表名] GROUP BY [字段] HAVING COUNT([字段]) > 1 );
然后就是删除重复数据,只保留一条ID最小的数据
DELETE FROM [表名] WHERE id IN ( SELECT * FROM ( SELECT id FROM [表名] WHERE [字段] IN ( SELECT [字段] FROM [表名] GROUP BY [字段] HAVING COUNT(1) > 1 ) AND id NOT IN ( SELECT MIN(id) FROM [表名] GROUP BY [字段] HAVING COUNT(1) > 1 ) ) AS table_repeat_copy );