I have a SQL table with two types of ID column. e.g.
ID_1 Name Date ID_2
487 Joe 09/06/2004 332
731 Mike 06/01/2004 116
487 Joe 09/06/2004 354
777 Rich 01/01/2002 455
745 Mike 06/01/2004 116
Sometimes ID_1 has multiple rows, with different values for ID_2. And vice versa, sometimes ID_2 has multiple rows, with different values for ID_1.
I would like to keep all rows where there is a one-to-one match between ID_1 and ID_2. Ideally, I would also make another table with the remaining rows, so I can easily look at them later. So the above example, only one row (the 4th one) has a one-to-one match between ID_1 and ID_2:
ID_1 Name Date ID_2
777 Rich 01/01/2002 455
All of the other rows have rows where one of the IDs is duplicated. So it is basically removing any rows where either of the ID columns is duplicated at all.
I have tried using DISTINCT, but that keeps one of the duplicate rows, while I want them all removed.
p.s. this is not a question about joining tables - the example is a single table.