My table
ANONYMOUS
ONE TWO
1 2
2 1
1 2
3 1
Now i want to select distinct set of one and two.
My selected list should be
ANONYMOUS
ONE TWO
1 2
3 1
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Your question isn’t very clear, but I guess you mean this:
It finds rows with
(one, two)where the reversed pair(two, one)does not exist. If both exist, it chooses the pair such thatone < two. It also selects rows where the values are equal.See it working online: sqlfiddle
If you would prefer to use a
JOINinstead ofNOT EXISTSyou can do that:See it working online: sqlfiddle