SQL select single distinct values from multiple columns (not combined values) -


for example, have following table:

userid department1 department2 ------------------------------ 1      sales       marketing 2      research 3      sales 

and want following results

distinctdepartments ------------------- sales marketing research 

i found lots of solutions show me distinct combined values of multiple columns, need overall distinct values, if values in same column.

thankyou

chris

try use union both columns

select department1  tab union  select department2  tab 

note: union command eliminates duplicates


Comments

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -