Select where count of another table is zero
sql
Solution
try,
SELECT q.*
FROM questions q LEFT OUTER JOIN answers a
ON q.id = a.questionid
WHERE a.questionid IS NULL
Problem
I have two tables (`questions` and `answers`), and wish to select the rows from `questions` only when the corresponding count in `answers` is zero, in other words, when there are no answers which match `questionid`. My query so far is: ``` SELECT q.* , COUNT(a.id) FROM questions q LEFT OUTER JOIN answers a ON q.id = a.questionid WHERE COUNT(a.id)=0 ``` I'm not sure if it's possible to do it like that, but it's not working. Any ideas? Thank you