mysql 單表多條件刪除重複數據

DELETE p1 FROM performance AS p1
LEFT JOIN (
  SELECT performance_id, fee_id,user_name FROM performance 
  GROUP BY USER_NAME,fee_id
  HAVING COUNT(fee_id) > 1
) AS p2 ON p1.user_name = p2.user_name AND p1.FEE_ID = p2.fee_id
WHERE p1.performance_id > p2.performance_id;

刪除以後,能夠添加惟一索引或者主鍵。sql

相關文章
相關標籤/搜索