SystemJay
08-11-2009, 11:55 PM
Hi!
My table looks like the following:
ID, value1, value2, value3 ..... value 12.
row: 123 1 0 0 1
row: 124 0 0 0 1
row: 125 1 1 1 1
What I need to do is to check one row at a time (with PHP) how many
number 1 entries does a single ID have in all those colums(value1-value12)
... I belive i got the PHP part right, so lets focus on SQL. (unless someone
insists telling me that too, since i'd love to see a comparison.)
Is there any more reasonable way to do this than:
SELECT value1, value2, value3, value4, value 5, value6, value7, value8, value9,value10,value11,value12 FROM ... ?
Cause what if I have ID, value1, value2 ..... value60?
I surely dont want to type SELECT value1 .... value60,
that query would look just plain silly.
Could anyone explain me what I have missed or have I? ta :thumbsup:
Cant seem to figure out how to do this reasonably. :(
My table looks like the following:
ID, value1, value2, value3 ..... value 12.
row: 123 1 0 0 1
row: 124 0 0 0 1
row: 125 1 1 1 1
What I need to do is to check one row at a time (with PHP) how many
number 1 entries does a single ID have in all those colums(value1-value12)
... I belive i got the PHP part right, so lets focus on SQL. (unless someone
insists telling me that too, since i'd love to see a comparison.)
Is there any more reasonable way to do this than:
SELECT value1, value2, value3, value4, value 5, value6, value7, value8, value9,value10,value11,value12 FROM ... ?
Cause what if I have ID, value1, value2 ..... value60?
I surely dont want to type SELECT value1 .... value60,
that query would look just plain silly.
Could anyone explain me what I have missed or have I? ta :thumbsup:
Cant seem to figure out how to do this reasonably. :(