Mysql JOIN problem
Posted
by FinalDestiny
on Stack Overflow
See other posts from Stack Overflow
or by FinalDestiny
Published on 2010-03-31T14:30:02Z
Indexed on
2010/03/31
14:33 UTC
Read the original article
Hit count: 363
I have 2 mysql tables :
Question with the following columns : id, question, nranswers
Nranswers must be a number from 1 to 5
And the other table is
Answers with the following columns: userid, answer .
Now the problem is that I want to get the replies for each answer for one question(id 22 let's say) .
P.S. If the nranswers is 3, the result should look like this:
(the right number means how many times the reply number was chosen)
1 - 2
2 - 8
3 - 7
If the nranswers is 5, the result should look like this:
1 - 3
2 - 8
3 - 14
4 - 19
5 - 8
Please help me out with the query, atm he's not counting the answers that weren't chosen, only the ones that were chosen at least one time.
© Stack Overflow or respective owner