码迷,mamicode.com
首页 > 数据库 > 详细

sql删除重复数据

时间:2017-08-03 15:07:02      阅读:149      评论:0      收藏:0      [点我收藏+]

标签:color   复数   select   span   delete   pre   数据   logs   begin   

 

 

begin tran 
delete from WxUser_BMUser  
where   OpenId in (  select a.OpenId from WxUser_BMUser a where  IsUnBind=0
group by a.OpenId having COUNT(1)>1
) 
and   id not in (select min(id) from WxUser_BMUser  where IsUnBind=0  group by OpenId     having count(1)>1) 

rollback
commit

 

sql删除重复数据

标签:color   复数   select   span   delete   pre   数据   logs   begin   

原文地址:http://www.cnblogs.com/yangjinwang/p/7279392.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!