普通注册 - 普通登录
开源之家-免费素材_软件_模板_源码下载-更快的站长下载站

开源之家-免费素材_软件_模板_源码下载-更快的站长下载站

织梦网站MYSQL查询重复记录的方法

更新时间:2020-12-15 19:38 文章类目:DEDE教程 文章来源:开源之家 作者:开源之家 浏览:105 次

1、查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断

select * from people   

where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1) 

织梦网站MYSQL查询重复记录的方法删除表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断,只留有rowid最小的记录  

delete from people   

where peopleId in (select peopleId from people group by peopleId   having count(peopleId) > 1)   

and rowid not in (select min(rowid) from people group by peopleId having count(peopleId )>1)   


3、查找表中多余的重复记录(多个字段)

select * from vitae a   

where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)   


4、删除表中多余的重复记录(多个字段),只留有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)   


5、查找表中多余的重复记录(多个字段),不包含rowid最小的记录

select * 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)   

转载请注明来源: 织梦网站MYSQL查询重复记录的方法

本文永久链接地址: https://www.enboo.cn/CMSjiaocheng/DEDEjiaocheng/22769.html

文本标签:织梦教程

郑重声明:
本站所有内容均由互联网收集整理、网友上传,并且以计算机技术研究交流为目的,仅供大家参考、学习,不存在任何商业目的与商业用途。
若您需要商业运营或用于其他商业活动,请您购买正版授权并合法使用。 我们不承担任何技术及版权问题,且不对任何资源负法律责任。
如无法链接失效或侵犯版权,请给我们来信:2225329841@qq.com