SQL删除重复数据

--删除表中重复的数据,只留有id最小的记录
delete from SiteShopCus
where mobile in (select mobile from SiteShopCus group by   mobile   having count(mobile) > 1)
and id not in (select min(id) from   SiteShopCus group by mobile having count(mobile )>1)

--删除表中多余的重复记录(多个字段),只留有rowid最小的记录

delete from vitae a
where (a.peopleId,a.seq) in   (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)
and rowid not in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)

原文地址:https://www.cnblogs.com/wangpf/p/3408075.html