I have a relational table that connects two other tables based on their IDs. There can be duplicates for both columns – but there CANNOT be the same row twice. I handle the checking code side.
How do I remove duplicate rows (see below):
select * from people:
a | b
1 2
1 3
1 3
1 7
2 3
2 5
2 5
2 9
I want the result to be:
a | b
1 2
1 3
1 7
2 3
2 5
2 9
That’s a constraint on the table that you have not implemented. The constraint is a
unique indexon(a,b). If you had the index you would not have duplicates.IMHO your best approach is to add the unique index to the table, using a temporary table to first remove the duplicates:
person_temppersonpersonunique a,bfromperson_tempto `person.