标签:blog http ar color sp 数据 on div art
在给一个客户上线的系统里发现有一张表里出现了重复的数据,结果通过排查代码发现确实业务逻辑有问题,在修改了代码后需要将为数据库里的重复数据删除
--删除重复的记录
delete from table1
--根据Uid号获取重复的记录
where uid in (select uid from table1 group by uid having count(uid) > 1)
--排除保留最新的ID号,其他的删除
and id not in (select max(id) from table1 group by uid having count(uid )>1)
标签:blog http ar color sp 数据 on div art
原文地址:http://www.cnblogs.com/huangtailang/p/4121012.html