deletefrom people where peopleId in (select peopleId from people groupby peopleId havingcount(peopleId) > 1) androwidnotin (selectmin(rowid) from people groupby peopleId havingcount(peopleId )>1)
3、查找表中多余的重复记录(多个字段)
1 2
select * from vitae a where (a.peopleId,a.seq) in (select peopleId,seq from vitae groupby peopleId,seq havingcount(*) > 1)
4、删除表中多余的重复记录(多个字段),只留有rowid最小的记录
1 2 3
deletefrom vitae a where (a.peopleId,a.seq) in (select peopleId,seq from vitae groupby peopleId,seq havingcount(*) > 1) androwidnotin (selectmin(rowid) from vitae groupby peopleId,seq havingcount(*)>1)
5、查找表中多余的重复记录(多个字段),不包含rowid最小的记录
1 2 3
select * from vitae a where (a.peopleId,a.seq) in (select peopleId,seq from vitae groupby peopleId,seq havingcount(*) > 1) androwidnotin (selectmin(rowid) from vitae groupby peopleId,seq havingcount(*)>1)