我有以下查询,它进行了 2 个内部连接。除非在评级表中没有 account_id 条目,否则这可以正常工作。
SELECT c.comment_id, a.account_id, a.first_name, a.second_name, a.points, a.image_url, c.body, c.creation_time, AVG(r.rating_overall)
FROM comments AS c
INNER JOIN accounts AS a
ON c.account_id=a.account_id
INNER JOIN ratings AS r
ON r.baker_id=a.account_id
WHERE c.blog_id = ?
GROUP BY c.comment_id, a.account_id, a.first_name, a.second_name, a.points, a.image_url, c.body, c.creation_time
ORDER BY c.creation_time DESC
即使评级表中没有条目,如何使此查询返回结果。换句话说AVG(r.rating_overall) = 0
,只要没有评级就生产?