SQL重复记录查询的几种方法
Posted 键盘上落下的泪
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SQL重复记录查询的几种方法相关的知识,希望对你有一定的参考价值。
http://www.jb51.net/article/34820.htm
\
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)
以上是关于SQL重复记录查询的几种方法的主要内容,如果未能解决你的问题,请参考以下文章