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 rowid 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
where rowid in (select min(rowid) from vitae group by peopleId,seq having count(*)>1)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29193965/viewspace-1589836/,如需轉載,請注明出處,否則将追究法律責任。
轉載于:http://blog.itpub.net/29193965/viewspace-1589836/