sql - 2-column distinct? -


i'm trying select 2 distinct numbers id1 , id2 following table:

tb_table1( bigint id1 bigint id2 bigint userid)

if

select distinct id1, id2 tb_table1  

i'll get, example, 2 rows, (111, 222) , (222,111).

i want 1 of rows since don't care column, id1, or id2 result gets returned in. basically, want distinct pairs order doesn't matter.

thoughts? in advance.

it remiss of me not point out suggests table not quite normalized should - when users acquire third id? anyway.

using fact union (as opposed union all) automatically de-duplicate, do

select id1, id2 tb_table1 id1 < id2 union select id2, id1 tb_table1 not id1 < id2 

Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -