var sidebar_align = 'right';
var content_container_margin = parseInt('290px');
var sidebar_width = parseInt('270px');
Unanswered: Get corresponding column names for certain data
I have a table with say 3 columns and I want to get all non-null values from these 3 columns AS WELL AS their corresponding column names. So if I have this:
I want the result to look like this:
Col1 Col2 Col3
---- ---- ----
Tom Hook Caren
Is there a query to do this? Many thanks.
SELECT Col1 AS Name
, 'Col1' AS ColName
WHERE Col1 IS NOT NULL
WHERE Col2 IS NOT NULL
WHERE Col3 IS NOT NULL
Hey, I didn't realize you wrote a book Rudy! That's great!
opel... why do you have three columns that are storing similar data?
Thanks alot. Is there a way to make the query slightly dynamic so that it can get the column name without having to hardcode it?
@Teddy: That was just an example. I guess I'm not very good at coming up with sensible examples!
Originally Posted by
you should redesign the table instead