一道SQL的题目:

来源:百度知道 编辑:UC知道 时间:2024/05/17 00:41:03
学生-课程数据中包括三个表:
学生表:S(Sno,Sname,Age,Sex),各属性分别表示学号,姓名,年龄,性别;
课程表:C(Cno,Cname,Teacher),各属性分别表示课程号,课程名,任课教师;
选课表:SC(Sno,Cno,Gread),各属性分别表示学号,课程号,成绩;
请用SQL语言完成以下操作:
1.检索选修课程名为"MS"的学生号和学生姓名;
2.检索至少选修了课程为"C1""C3"的学生号;
3.检索年龄在18到20之间(含18和20)的女生的学号,姓名及年龄;
4.检索选修全部课程的学生姓名;
5.检索至少选修了学生"1042"选修的全部课程的学生号码.

1. select sno,sname from s,c,sc where s.sno = sc.sno and c.cno = sc.cno and c.cname = 'MS'

2. select sno,sname from s,c,sc where s.sno = sc.sno and c.cno = sc.cno and c.cname in ('C1','C3')

3. select sno,sname,age from s where age >= 18 and age <=20 and sex='女'

4. select sno,sname from s,c,sc where s.sno = sc.sno and c.cno = sc.cno (全部课程不知怎么取)

5.select sno from s,c,sc where s.sno = sc.sno and c.cno = sc.cno
and s.sno and sno exisit (
select cno from sc where sno = '1042')