mysql 删除同样记录只保留一条

delete from fa_order_account
where order_id in (select  order_id from  (select order_id from  fa_order_account  a  group by a.order_id having count(a.order_id) > 1) as a)
and id not in (select id from (select min( id) id from fa_order_account group by  order_id having count( order_id)>1) as b)

 

posted @ 2019-06-11 14:43  huanghaunghui  阅读(753)  评论(0编辑  收藏  举报