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 DISTINCT MAILING_ID,REPORT_IDFROM table_1 ; The problem is that I want to remove duplicates by col1 and col2, but also want to include to the insert all the other fields of table_1.
I tried to add all the relevant columns this way:
INSERT IGNORE INTO temp(M_ID,MAILING_ID,REPORT_ID, MAILING_NAME,VISIBILITY,EXPORTED) SELECT DISTINCT M_ID,MAILING_ID,REPORT_ID,MAILING_NAME,VISIBILITY, EXPORTED FROM table_1 ; M_ID(int,primary),MAILING_ID(int),REPORT_ID(int), MAILING_NAME(varchar),VISIBILITY(varchar),EXPORTED(int) But it inserted all rows into temp (including duplicates)




INSERT IGNOREin your case, 2nd --> How is your db table set up?