技术动态
联系我们
地址:贵州省贵阳市南明区中华南路新大陆电脑城2楼3A
销售电话:0851-85273506 18798806075 徐小姐
商务QQ:1480815590/652144177
技术电话:
18198536608/18586800417
主页 > 资讯动态 > 技术动态 > 技术动态
sql语句删除数据库表中重复记录只保留一条
2014-12-10 22:06  点击数:
来源:捷成网络

sql语句删除数据库表中重复记录,删除表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断,只留有rowid最小的记录

delete from A
where   peopleName in (select peopleName    from A group by peopleName      having count(peopleName) > 1)
and   peopleId not in (select min(peopleId) from A group by peopleName     having count(peopleName)>1)

delete from A
where peopleName in (select peopleName from A group by peopleName having count(peopleName)>1)
and peopleId not in (select min(peopleId) from A group by peopleName having count(peopleName)>1)
友情链接

Copyright @ 2013-2015 制作:捷成网络 贵州金方象版权所有 备案号:黔ICP备15003149号