sql删除重复数据

 

 

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

 

posted @ 2017-08-03 14:05  秋香姑娘请你不要紧张  阅读(227)  评论(0编辑  收藏  举报