第1关:子查询
1、SQL子查询使用的量词包括___BCD___。
A、EXISTS
B、ANY
C、SOME
D、ALL
2、经常与子查询一起使用的运算符有__ABCD____。
A、IN
B、EXISTS
C、ANY
D、ALL
3、使用EXISTS实现子查询时,必须使用内、外查询的相同意义的列进行比较运算。(B)
A、对
B、错
第2关:子查询-练习
use course;
/****请在此编写代码,操作完毕之后点击评测******/
/**********Begin**********/
select * from teacher where department_id="101";
/**********End**********/
第3关:子查询-练习一
use course;
/****请在此编写代码,操作完毕之后点击评测******/
select distinct student_id,student_name
from student
where student_id
in(select distinct student_id from choose where score=82);
select distinct student_id,student_name
from student
where student_id
in (select distinct student_id from choose group by student_id having avg(score)>70);
/**********End**********/
第4关:子查询-练习二
use course;
/****请在此编写代码,操作完毕之后点击评测******/
/**********Begin**********/
select distinct student.student_id,student.student_name
from student INNER join choose on student.student_id=choose.student_id
WHERE choose.score>=ALL
(select score from choose where student_id='201710201102');
select distinct department_id,department_name
from department
where department_id
not in (SELECT DISTINCT department_id FROM teacher);
/**********End**********/
第5关:子查询-练习三
use course;
/****请在此编写代码,操作完毕之后点击评测******/
/**********Begin**********/
( select s.student_id 学工号, student_name 姓名, gender 性别
from student s join choose c on s.student_id=c.student_id
group by s.student_id
order by sum(score) desc limit 3 )
union
( select teacher_id, teacher_name, gender from teacher
order by teacher_id desc limit 2
)
/**********End**********/