使用内部联接获取每个问题的答案数量
SELECt thread_question.question_id, COALESCE(sub.counts,0) AS NumerOfAnswer FROM thread_question LEFT JOIN ( SELECt question_id, COUNT(answer_id) AS counts FROM thread_answer GROUP BY question_id ) sub ON thread_question.question_id = sub.question_id ORDER BY NumerOfAnswer
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)