数据库重复数据是什么
2023-04-26 · 百度认证:重庆猪八戒网络有限公司官方账号
1、查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断
select*frompeople
wherepeopleIdin(selectpeopleIdfrompeoplegroupbypeopleIdhavingcount(peopleId)>1)
2、删除表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断,只留有rowid最小的记录
deletefrompeople
wherepeopleIdin(selectpeopleIdfrompeoplegroupbypeopleIdhavingcount(peopleId)>1)
androwidnotin(selectmin(rowid)frompeoplegroupbypeopleIdhavingcount(peopleId
)>1)
3、查找表中多余的重复记录(多个字段)
select*fromvitaea
where(a.peopleId,a.seq)in(selectpeopleId,seqfromvitaegroupbypeopleId,seqhavingcount(*)>1)
4、删除表中多余的重复记录(多个字段),只留有rowid最小的记录
deletefromvitaea
where(a.peopleId,a.seq)in(selectpeopleId,seqfromvitaegroupbypeopleId,seqhavingcount(*)>1)
androwidnotin(selectmin(rowid)fromvitaegroupbypeopleId,seqhavingcount(*)>1)
5、查找表中多余的重复记录(多个字段),不包含rowid最小的记录
select*fromvitaea
where(a.peopleId,a.seq)in(selectpeopleId,seqfromvitaegroupbypeopleId,seqhavingcount(*)>1)
androwidnotin(selectmin(rowid)fromvitaegroupbypeopleId,seqhavingcount(*)>1)