查询是否有重复的记录
SELECT * FROM 表名 GROUP BY 字段名 HAVING COUNT(1) > 1;
查看是否是需要删除的记录
SELECT *
FROM 表名 where id not in (
SELECT id from (SELECT MIN(id) id FROM 表名 GROUP BY 重复字段名) a
);
删除对应的记录
DELETE
FROM 表名 where id not in (
SELECT id from (SELECT MIN(id) id FROM 表名 GROUP BY 重复字段名) a
);
评论 (0)