I have a table with 2 fields (name, interest) and I want to find all pairs that have the same interest, with all duplicates and mirrored pairs removed.
I am able to find
Suppose we have table Name
with tuples:
F1 F2
Jon Smith
Smith Jon
then to remove this pair we can make query like this:
SELECT n1.F1, n1.F2
FROM Name n1
WHERE n1.F1 > (SELECT n2.F1
FROM Name n2
WHERE n1.F1=n2.F2)
So Instead of using <>
in
(SELECT * FROM Matches
WHERE name2 **<>** (select name1 from Matches);)
use >
or <
operator and It should work fine.