MySQL Forums :: Newbie :: select * where value>1


Advanced Search

select * where value>1
Posted by: yuval halpern ()
Date: August 24, 2011 04:17PM

Hi,
Im learning php and mysql while building a website for composers.
I have 2 questions.
I have a table with the following columns
instrument1,instrument2, instrument3etc.

the table will look like this
-----------------------------------------
ID| instrument1|instrument2|instrument3|etc....
-----------------------------------------
1 | 0 | 1 | 0 |
------------------------------------
2 | 2 | 0 | 1 |
---------------------------------
etc.

I would like to select a row according to ID but also checking if the instruments value is =>1.
So if i choose ID=1 i will get instrument2->1
if i choose ID=2 i will get instrument1->2 and instrument3->1

My question is how do i make a reference to the value of a cell in mysql without having to put the name of the column.(there might be 20 instruments)
or if you have a better idea how to do it.

Another question:
How can i reset the values of a specific row, such as Id=1. so all the instruments have a 0 instead of a 1.

hope my questions are clear. thanks for your help. i couldnt find any examples relevant using google.
cheers
yuval

Options: ReplyQuote


Subject Written By Posted
select * where value>1 yuval halpern 08/24/2011 04:17PM
Re: select * where value>1 Barry Galbraith 08/24/2011 05:51PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.