WE have a database with a few tables, one of them features the columns
id | 1score | 1seen | 1pdp | 1red | 2score | 2seen | 2pdp | 2red | 3score | 3seen | 3pdp | 3red | 4score | 4seen | 4pdp | 4red | 5score | 5seen | 5pdp | 5red | 6score | 6seen | 6pdp | 6red | 7score | 7seen | 7pdp | 7red | 8score | 8seen | 8pdp | 8red | 9score | 9seen | 9pdp | 9red | 10score | 10seen | 10pdp | 10red
I need to create a SQL query that will go through each row and count the number of *red it finds.
So for example if one rown has 1red, 4red and 8red set to 1 (NULL is default) then the sql will say there are
FOUND 3 items in 1 record
if it searches 10 records and finds 15 instances of *red it will display
FOUND 15 items in 10 records
Is this possible with that database table structure?
I can find out the number of records that features a red set to 1, but not the total instances. To find the number of records I am using
id | 1score | 1seen | 1pdp | 1red | 2score | 2seen | 2pdp | 2red | 3score | 3seen | 3pdp | 3red | 4score | 4seen | 4pdp | 4red | 5score | 5seen | 5pdp | 5red | 6score | 6seen | 6pdp | 6red | 7score | 7seen | 7pdp | 7red | 8score | 8seen | 8pdp | 8red | 9score | 9seen | 9pdp | 9red | 10score | 10seen | 10pdp | 10red
I need to create a SQL query that will go through each row and count the number of *red it finds.
So for example if one rown has 1red, 4red and 8red set to 1 (NULL is default) then the sql will say there are
FOUND 3 items in 1 record
if it searches 10 records and finds 15 instances of *red it will display
FOUND 15 items in 10 records
Is this possible with that database table structure?
I can find out the number of records that features a red set to 1, but not the total instances. To find the number of records I am using
Code:
SELECT count(*)
FROM myTable
WHERE 1red = '1'
OR 2red = '1'
OR 3red = '1'
OR 4red = '1'
OR 5red = '1'
OR 6red = '1'
OR 7red = '1'
OR 8red = '1'
OR 9red = '1'
OR 10red = '1'