Find and remove duplicate rows by two columns

前端 未结 7 593
鱼传尺愫
鱼传尺愫 2021-02-01 08:52

I read all the relevant duplicated questions/answers and I found this to be the most relevant answer:

INSERT IGNORE INTO temp(MAILING_ID,REPORT_ID) 
SELECT DISTI         


        
相关标签:
7条回答
  • 2021-02-01 09:45

    you can always get the primary ids by grouping that two unique fields

    select count(*), id as count from table group by col a, col b having count(*)>1;

    and then

    delete from table where id in ( select count(*), id as count from table group by col a, col b having count(*)>1) limit maxlimit;

    you can also use max() in place of limit

    0 讨论(0)
提交回复
热议问题