Hi,
I am trying to obtain the column name of a data item in the database.
For example if I have a table A with a column reptiles. In this column reptiles I have an entry snake.
Now if I know about the value snake , how can I obtain its column name(which in the example is reptiles) using an sql statement.
I appreciate your help.
Thanks
-Nayeem
getting a column name based on a value
Moderator: General Moderators
Re: getting a column name based on a value
Sounds weird.nayeemmz wrote:For example if I have a table A with a column reptiles. In this column reptiles I have an entry snake.
What are the other columns of that table?
- ReverendDexter
- Forum Contributor
- Posts: 193
- Joined: Tue May 29, 2007 1:26 pm
- Location: Chico, CA
So what you're looking for would effectively be like the following? (though the following certainly doesn't work!)
EDIT: reading is hard
Code: Select all
SELECT column_name
FROM table
WHERE data = "snake"