mysql - SQL Query: How to get items from one col paired with another but not visa versa -
i need query returns rows cola paired colb treat same values in opposite direction duplicates , removed.
the best way explain query example:
cola | colb ----------- abc | def def | abc asdf | 1234 1234 | asdf other| row 1234 | test
sql magic
cola | colb ----------- abc | def asdf | 1234 other| row 1234 | test
it removes rows 'duplicate' in other direction.
any appreciated.
if prefer "clean" sql solution (without least()
or greatest()
) job:
select cola, colb your_table cola > colb or (colb, cola) not in (select cola, colb your_table)
Comments
Post a Comment