当前位置:主页 > 网站优化 >

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

奕星seo伪原创
作者: 奕星SEO 分类: 网站优化 发布时间: 2020-03-17 02:52 内容来源:网络整理阅读量:

织梦网站MYSQL查询重复记录的方法 织梦无忧 标签调用 2020-03-14 12:04

摘要: 1、查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断 select * from people where peopleId in (select peopleId from people group by peopleId having count(peopleId) 1) 2、删除表中多余的重复记录,重复记录是根据单个字段(peopleId

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

select * from people   

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

2、删除表中多余的重复记录,重复记录是根据单个字段(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)   

本文链接:

版权声明:本站资源均来自互联网或会员发布,如果侵犯了您的权益请与我们联系,我们将在24小时内删除!谢谢!


本文链接地址:http://www.seohuizhou.com/webyouhua/26314.html
上一篇:<<织梦文章命名规则{cc}还原真实文章id便于实现伪静态
下一篇:织梦会员邮件验证通知在https域名下验证链接404错误的解决方法>>