我想向所有学生展示即使他们没有注册课程。我如何修改此查询以显示null?
SELECT a.lastname,
Count(c.credits) TotalCredits
FROM students a
INNER JOIN registration b
ON a.studentid = b.studentid
INNER JOIN courses c
ON b.courseid = c.coursenumber
GROUP BY a.studentid
查询由John Woo完成
答案 0 :(得分:1)
使用LEFT
代替INNER
:
SELECT a.lastname,
Count(c.credits) TotalCredits
FROM students a
LEFT JOIN registration b
ON a.studentid = b.studentid
LEFT JOIN courses c
ON b.courseid = c.coursenumber
GROUP BY a.studentid