By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,640 Members | 2,118 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,640 IT Pros & Developers. It's quick & easy.

How do I select columns with a certain value?

P: 1
I am trying to figure out if it is possible to select all the column names that have a value of "1", and not a null or value of zero from my table.

I can SELECT all columns and get the names, but what I want is the query to return the names of only those columns that have a data value of "1".

I thought of doing a WHERE but I am unsure of how to specify the data value instead of a column name for the selection.
Apr 29 '11 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 1,206
A WHERE clause is what you need.

Expand|Select|Wrap|Line Numbers
  1. SELECT my_field FROM my_table WHERE my_field = 1
May 5 '11 #2

Post your reply

Sign in to post your reply or Sign up for a free account.