How to find all duplicates in a link table?

I have a table with these columns:

1. ID_Table1 2. ID_Table1LinkTable2 3. ID_Table1LinkTable2 

I need to find all duplicates in columns ID_Table1LinkTable2, ID_Table1LinkTable2

And drop these lines.

How can i do this?

Thanks for the promotion

As an example, I have

 ID_Table1 ID_Table1LinkTable2 ID_Table1LinkTable2 -------------------------------------------------- 1 123 322 2 123 432 3 123 3432 4 123 322 

I need to discard the last line

+4
source share
2 answers
 delete from yourtable where ID_Table1 not in (select MIN(ID_Table1) from yourtable group by ID_Table1LinkTable2, ID_Table1LinkTable2) 
+6
source

ALTER IGNORE TABLE table ADD UNIQUE(ID_Table1)

ALTER IGNORE TABLE table ADD UNIQUE(ID_Table1LinkTable2)

This will remove duplicates.

-2
source

All Articles