mysql中删除重复记录,只保留一条

 


DELETE FROM stock_market WHERE date='2021-03-19' AND code IN (SELECT code FROM (SELECT code FROM stock_market where date='2021-03-19' GROUP BY code HAVING COUNT(code)>1) e)
 AND id NOT IN (SELECT id FROM (SELECT MIN(id) AS id FROM stock_market where date='2021-03-19' GROUP BY code HAVING COUNT(code)>1) t)

posted @ 2021-03-26 12:44  锐洋智能  阅读(42)  评论(0编辑  收藏  举报