新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
MYSQL查詢重復(fù)記錄的方法
MYSQL查詢重復(fù)記錄的方法很多,下面就為您介紹幾種最常用的MYSQL查詢重復(fù)記錄的方法,希望對您學(xué)習(xí)MYSQL查詢重復(fù)記錄方面能有所幫助。

1、查找表中多余的重復(fù)記錄,重復(fù)記錄是根據(jù)單個字段(peopleId)來判斷
- select * from people
- where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1)
2、刪除表中多余的重復(fù)記錄,重復(fù)記錄是根據(jù)單個字段(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、查找表中多余的重復(fù)記錄(多個字段)
- select * from vitae a
- where (a.peopleId,a.seq) in (select peopleId,seq from vitae group by peopleId,seq having count(*) > 1)
4、刪除表中多余的重復(fù)記錄(多個字段),只留有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、查找表中多余的重復(fù)記錄(多個字段),不包含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)
網(wǎng)頁題目:MYSQL查詢重復(fù)記錄的方法
當(dāng)前URL:http://fisionsoft.com.cn/article/cdgcipo.html


咨詢
建站咨詢
