1350. 院系无效的学生

文章访问量:

LEFT JOIN

https://leetcode.cn/problems/students-with-invalid-departments/

这个就不能用大表left join小表了,大表left join小表旨在求出那些在大表中,都能在小表中找到对应的匹配项的记录。这题是反过来,要求找不到匹配项,即 is null的记录,所以得小表left join大表。

SQL
# Write your MySQL query statement below
SELECT A.id,A.name
FROM Students AS A 
LEFT JOIN Departments AS B 
ON A.department_id = B.id
WHERE B.name is NULL
Subscribe
提醒
0 评论
Inline Feedbacks
View all comments
0
在此留下你的评论x