日期:2014-05-16  浏览次数:20415 次

数据库重复数据处理

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

?例二:
?select?*?from?testtable
?where?numeber in (select?number?from?people?group by?number?having count(number) > 1 )
?可以查出testtable表中number相同的记录
2
、删除表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断,只留有rowid最小的记录
where?peopleId??in?(select??peopleId??from?people??group??by??peopleId???having??count(peopleId)?>?1
)
and?rowid?not?in?(