|
SELECT * FROM author GROUP BY author HAVING COUNT(author)>1
这句会显示 作者重复的记录
SELECT total,`distinct`,total - `distinct` FROM (SELECT COUNT(*) as total,COUNT(DISTINCT(author)) as `distinct` FROM author) tmp
这个结果 会 大于/等于 第一句语句的结果
SELECT COUNT(*) FROM author GROUP BY author HAVING COUNT(author)>1 再用这句判断一下
是因为 重复有可能是重复多次
一次性 删除重复记录
DELETE author AS a FROM author AS a,(SELECT MIN(id) AS id,author FROM author GROUP BY author HAVING COUNT(author)>1) AS b WHERE a.author=b.author AND a.id<>b.id |