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) 

sql fiddle


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -