maunded
asked on
Find column name by value
Hi,
Im trying to find the name of a column using a value in that column. I know it could be ambigious, but I'll have to deal with that.
What I have is a table like:
ID | Input1 | Input2 | Input3 | Input4
-------------------------- ---------- --------
1 | front | back | top | side
2 | water | fire | earth | air
-------------------------- ---------- --------
I have the ID and one of the values in the table, but I need to be able to find the column that that value belongs to.
Is this possible?
Thanks
D.
Im trying to find the name of a column using a value in that column. I know it could be ambigious, but I'll have to deal with that.
What I have is a table like:
ID | Input1 | Input2 | Input3 | Input4
--------------------------
1 | front | back | top | side
2 | water | fire | earth | air
--------------------------
I have the ID and one of the values in the table, but I need to be able to find the column that that value belongs to.
Is this possible?
Thanks
D.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Both very nice, thank you.
Try:
Select 'Input1' from yourtable where Input1 = 'YourValue'
Union
Select 'Input2' from yourtable where Input2 = 'YourValue'
Union
Select 'Input3' from yourtable where Input3 = 'YourValue'
Union
Select 'Input4' from yourtable where Input4 = 'YourValue'