ITeye博客

sql删除重复记录

cfyme · 2015-09-16 14:46 · mysql · 数据库 · Markdown

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);

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。