查找表中多余的重復(fù)記錄擎值,重復(fù)記錄是根據(jù)單個(gè)字段(DocId)來判斷
select * from TableName
where DocId in (select DocId from TableName group by DocId having count(DocId) > 1)
例二:
select * from TableName
where UserName in (select UserName from TableName group by TableName having count(TableName) > 1 )
可以查出表中UserName相同的記錄
2慌烧、刪除表中多余的重復(fù)記錄,重復(fù)記錄是根據(jù)單個(gè)字段(DocId)來判斷鸠儿,只留有DocId最小的記錄
delete from TableName
where DocId in (select? DocId from TableName group by DocId? having count(DocId) > 1)
and DocId not in (select min(DocId) from? TableName group by DocId having count(DocId)>1)