MySQL删除重复数据,只保留最早一条

2019-11-05  本文已影响0人  QinHaolei
DELETE FROM 表1
  WHERE ( 字段1,字段2 ) IN( SELECT 字段1,字段2 FROM 表1
  GROUP BY 字段1,字段2 HAVING COUNT(*) >1)
  AND id NOT IN(SELECT MIN(id) 
  FROM 表1 
  GROUP BY 字段1,字段2HAVING COUNT(*) >1)
上一篇 下一篇

猜你喜欢

热点阅读