I am making a survey-application in winforms that is connected to a MySQL database. Now I want to show the alternatives of a question, and how many answered each question. I have a table for alternatives called tblAlt and a table for answers from users called tblAnswers.
There are only 5 alternatives for each question. Is there a way to get each alternative, and how many answered each of them with one query?
This is what I made so far, but this is definitely wrong:
SELECT tblAlt.altText, Count(tblAnswers.answerID)
FROM tblAlt, tblAnswers
WHERE tblAlt.questionID = " & CInt(questionID) & "
AND tblAnswers.altID = tblAlt.altID
Tables involved are:
_______________ _______________ ___________ _______________
|_tblUsers____| |_tblAnswers___| |_tblAlt__| |_tblQuestion_|
| userID | | answerAltID | | altID | | questID |
| username | | userID | | altText | | questText |
|_____________| |______________| |_questID_| |_____________|
Any help would be appreciated!
I’m having trouble understanding your schema, hope this helps: