January 29th, 2008, 03:50 PM
Selecting multiple columns as one column
Hi everyone. First time posting. I did a search and could not find what I was looking for. Hopefully someone can answer this.
I am trying to SELECT multiple columns as one column for display. Something like this (which obviously does not work):
I have also tried:
Am I even close?
January 29th, 2008, 03:57 PM
select concat(column1, ', ', column2) as combinedlist
where 'data1' in(column1, column2)
order by combinedlist
January 29th, 2008, 04:01 PM
Sorry, I should have explained better. I do not actually want it listed as "column1, column2" in the results. Maybe an example would be good.
Originally Posted by jcarouth
Say column1 had:
Say column2 had:
I want my resulting combinedlist to have:
January 29th, 2008, 04:04 PM
January 29th, 2008, 04:05 PM
select column1 as name
order by name
January 29th, 2008, 04:07 PM
note that UNION vs UNION ALL will give you no duplicates for the former and duplicates for the latter (e.g. if David is in both column1 and column2 then using UNION you will have only one 'David' in the results whereas UNION ALL will give you two or more).
January 29th, 2008, 04:15 PM
That worked perfectly! Thank you everyone! And thanks jcarouth
for the explanation between UNION and UNION ALL. This forum is great.
October 26th, 2012, 11:04 PM
a question on counting unions
lets say i wanted to COUNT total occurrences in multiple columns how would i do that?
to make this
October 27th, 2012, 01:06 PM
Originally Posted by karnival800
FROM ( SELECT column1 AS name
FROM daTable ) AS u