Jump to content

Is it possible to Select distinct value from different columns?


abdfahim

Recommended Posts

Something like this is closer:

select distinct(col1) as a from table1 union select distinct(col2) as a from table2;

 

But you could get a duplicate if the same data is in different columns.  If this is the case, you could try a subquery:

 

select distinct(a) from (select distinct(col1) as a from table1 union select distinct(col2) as a from table2) as foo

 

cheers

-pnj

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.