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

相关文章
相关标签/搜索