SQL删除重复数据只保留一条

http://blog.csdn.net/anya/article/details/6407280/

 

2、删除表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断,只留有rowid最小的记录
delete from people
where   peopleName in (select peopleName    from people group by peopleName      having count(peopleName) > 1)
and   peopleId not in (select min(peopleId) from people group by peopleName     having count(peopleName)>1)

posted @ 2017-12-26 20:21  LuoCore  阅读(191)  评论(0编辑  收藏  举报