hey! So currently I have a database with 8 columns which correspond to 8 questions. Each question can have a response ranging from 1-5 as a value. Currently, I am using this for each question: SELECT q1, count(*) FROM table GROUP BY q1 Code (markup): The limitations are: 1- It will not show a 0 for a response which noone has chosen. 2- It would be way too many queries to run if I wanted to take the values and display with php. Is there any other way of achieving the same thing? Ideally, what I would want is a count per responses per question. Something that I can then take to PHP and generate a variable with and use to populate a summary table. How best can I do this?
The count in only 1 table can't show you the values that are not in the table... To do this, you may have two other tables which contains the questions, and all the possible choices to each question. You'll have something like this : select C.choice_id, count(*) from questions Q, choices C, answers A where Q.question_id = C.question_id ans A.choice_id (+)= C.choice_id group by C.choice_id