PDA

View Full Version : MYSQL - Most common answer



Neolumi
September 6th, 2007, 06:18 AM
Hey people, yet another mysql question.

responses
=========
id
question
answer

questions
=========
id
title

answers
=========
id
value

what I need to do is get the most common answer, so far I've got this:

SELECT a.ques_id, a.ques_title, ????(b.respa_answer) AS common_answer, c.qua_value
FROM inter_questions AS a
LEFT JOIN inter_respondant_answers AS b ON b.respa_question = a.ques_id
RIGHT JOIN inter_question_answers AS c ON b.respa_answer = c.qua_parent
GROUP BY a.ques_title
ORDER BY a.ques_idIs this going to take variables? :/

Edit: BTW the number of possible answers is variable