本关任务:根据提供的表和数据,查询至少学了
Oliver
同学所学的全部课程的其他同学的信息(学号s_id
,姓名`s_name)。
student
表数据:
s_id s_name s_sex 01 Mia 女 02 Riley 男 03 Aria 女 04 Lucas 女 05 Oliver 男 06 Caden 男 07 Lily 女 08 Jacob 男
course
表数据:
c_id c_name t_id 01 Chinese 02 02 Math 01 03 English 03
teacher
表数据:
t_id t_name 01 张三 02 李四 03 王五
score
表部分数据:
s_id c_id s_score 01 01 80 01 02 90 01 03 99 02 01 70 ... ... ...
SELECT s1.s_id, s1.s_name
FROM student s1
WHERE s1.s_name != 'Oliver'
AND NOT EXISTS(SELECT 1 FROM course c WHERE c.c_id IN(SELECT c_id FROM score WHERE s_id = (SELECT s_id FROM student WHERE s_name = 'Oliver')) AND NOT EXISTS(SELECT 1 FROM score sc WHERE sc.s_id = s1.s_id AND sc.c_id = c.c_id)
);