SELECT questions.id AS question_id, questions.title AS question_title, options.description AS option_desc, options.id AS option_id, count( answers.id ) AS answers_count
FROM questions, options, answers
WHERE options.question = questions.id
AND (
options.type = 'radio'
)
AND answers.option_id = options.id
AND questions.inquiry =39
AND answers.response
NOT IN (
SELECT answers.response
FROM answers
WHERE answers.inquiry =39
AND answers.option_id
IN ( 485 )
)
GROUP BY options.id
ORDER BY question_id, answers_count DESC
id select_type table type possible_keys key key_len ref rows Extra
1 PRIMARY answers ALL NULL NULL NULL NULL 3814 Using where; Using temporary; Using filesort
1 PRIMARY options eq_ref PRIMARY,question PRIMARY 4 samla.answers.option_id 1 Using where
1 PRIMARY questions eq_ref PRIMARY,inquiry PRIMARY 4 samla.options.question 1 Using where
2 DEPENDENT SUBQUERY answers index_subquery response response 4 func 11 Using index; Using where