I'm making a Q&A site, similar to this site and Yahoo answers. I have 3 tables - smf_members, qa_questions and qa_answers.
In this query, I want to select some fields from qa_questions, a few fields from smf_members and the number of records in ga_answers for the question_id. This is so I can have some basic info on the question, some basic info on the member, and the number of answers.
This is the query I've produced so far and it almost works, but doesn't return questions with which have no answers (ie, no records in the answers table for this question_id).
SELECT qa_questions.question_id,
qa_questions.question_title,
qa_questions.question_content,
qa_questions.time_asked,
qa_questions.question_author,
qa_questions.votes,
qa_questions.views,
qa_questions.pretty_url,
smf_members.real_name,
smf_members.id_member,
COUNT(qa_answers.question_id) AS answers
FROM qa_questions,
qa_answers,
smf_members
WHERE qa_questions.deleted = 0
AND smf_members.id_member = qa_questions.question_author
AND qa_answers.question_id = qa_questions.question_id
ORDER BY qa_questions.time_asked DESC
LIMIT 10