`
cfyme
  • 浏览: 263428 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

sql删除重复记录

 
阅读更多

mysql 删除重复记录,保留最新的一条:

delete from wechat_exchange_address
    where open_id in (select  open_id from  (select open_id from  wechat_exchange_address  a  group by a.open_id having count(a.open_id) > 1) as a) 
    and id not in (select id from (select max( id) id from wechat_exchange_address group by  open_id having count( open_id)>1) as b);

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics