标签:
例子1:查找一个表中的重复数据,重复记录是根据单个字段(Id)来判断,表名为STUDENT
SELECT ID ,
COUNT(1) FROM STUDENT T GROUP BY T.ID HAVING COUNT(ID) > 1
例子2:删除表中多余的重复记录,重复记录是根据单个字段(Id)来判断,只留有rowid最小的记录,表名为STUDENT
DELETE FROM STUDENT WHERE ID IN (SELECT ID FROM STUDENT T GROUP BY T.ID HAVING COUNT(ID) > 1) AND ROWID NOT IN (SELECT MIN(ROWID) FROM STUDENT T GROUP BY T.ID HAVING COUNT(T.ID) > 1)
标签:
原文地址:http://www.cnblogs.com/qadyyj/p/5737796.html