List column name when value in a row equals......
Posted: Sat Sep 18, 2004 2:46 pm
Hi,
I am trying to figure out how I can do this.
I want to return a column name when a value in a row = XXX. Here is an example.
I have an ID, so I can pull all data from the row in a select statement. I want to then find out the column name when any of 5 columns equals 1. Basically, these 5 columns can have 1 through 5 with no repeated values. Example results from query:
select * from testtable where id = '1';
Would return this
id = 1, testcolumn1 = 3, testcolumn2 = 2, testcolumn3 = 1, testcolumn4 = 5, and testcolumn5 = 4
I want to pull test3 column name.
Any help would be greatly appreciated.
THANKS!
I am trying to figure out how I can do this.
I want to return a column name when a value in a row = XXX. Here is an example.
I have an ID, so I can pull all data from the row in a select statement. I want to then find out the column name when any of 5 columns equals 1. Basically, these 5 columns can have 1 through 5 with no repeated values. Example results from query:
select * from testtable where id = '1';
Would return this
id = 1, testcolumn1 = 3, testcolumn2 = 2, testcolumn3 = 1, testcolumn4 = 5, and testcolumn5 = 4
I want to pull test3 column name.
Any help would be greatly appreciated.
THANKS!