2013年10月9日

如何去掉数据库重复记录并且只保留一条记录

摘要: 在n条记录里,存在着些相同的记录,如何能用SQL语句,删除掉重复并保留一条呢?方法如下:1、查找表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断[sql]select * from people where peopleId in (select peopleId from people group by peopleId having count(peopleId) > 1) 2、删除表中多余的重复记录,重复记录是根据单个字段(peopleId)来判断,只留有rowid最小的记录[sql]delete from people where peopleId in (s 阅读全文

posted @ 2013-10-09 12:48 awk 阅读(204) 评论(0) 推荐(0)

合并数据库重复记录处理

摘要: 1.updatemem_localmemberbaseinfosetbalance=(selectbfrom(selectcount(uniqueid)asa,sum(balance)asbgroupbyuniqueidhavingcount(uniqueid)>1)x)whereuniqueid=(selectdfrom(selectcount(uniqueid)asc,uniqueid asdgroupbyuniqueidhavingcount(uniqueid)>1)x)andid>100000;2.delete from mem_localmemberbaseinfo 阅读全文

posted @ 2013-10-09 11:49 awk 阅读(400) 评论(0) 推荐(0)

导航