Let\'s say that a query result is supposed to return a list of string pairs (x, y). I am trying to eliminate the reverse duplicates. What I mean is, if (x, y) was one of the
First of all, welcome to 2012. We have migrated away from relating tables using commas. It was introdued in ANSI 89 but is severely lacking. Nowaways, the correct way is to write queries using the ANSI 92/99/2003 JOIN syntax.
The solution to your problem is to turn your bidirectional inequality <>
into a unidirectional inequality, either <
or >
whichever you prefer.
select e.column3, f.column3
from example as e
join example as f on e.column2 = f.column2 and e.column3 < f.column3
select e.column3, f.column3 from example as e, example as f where e.column2 = f.column2
and e.column3 <> f.column3 where e.id < f.id
adding a simple where clause should do it.