急!关于用SQL语句表达数据库查询

假设学生-课程数据库关系模式如下:
Student(Sno,Sname,Sage,Ssex)
Course(Cno,Cname,Teacher)
SC(Sno,Cno,Grade)
用SQL语句表达下列查询:
(1)找出刘老师所授课程的课程号和课程名
(2)找出年龄小于22岁女生的学号和姓名
(3)找出至少选修刘老师讲的一门课的学生姓名
(4)找出“程序设计”课成绩在90分以上的学生姓名
(5)找出不学C3课的学生姓名
(6)找出至少选修C1课和C2课的学生学号
只要这题有答案,能理解,就能掌控SQL查询了,谢谢

1、select Cno,Cname from Course where Teacher='刘老师';

2、select Sno,Sname from Student where Sage < 22;

3、select Sname from Student where Sno not in(
select Sno from sc inner join Course on sc.Cno=Course.Cno where Course.Teacher='刘老师');

4、select Sname from Student where Sno in(
select Sno from sc inner join Course on sc.Cno=Course.Cno where sc.Grade>90 and Course.Cname='程序设计');

5、select Sname from Student where Sno not in(
select Sno from sc inner join Course on sc.Cno=Course.Cno where Course.Cname='C3课');

6、select Sno from Student where Sno not in(
select Sno from sc inner join Course on sc.Cno=Course.Cno where Course.Cname='C1课' or Course.Cname='C2课')
group by Sno having count(*) >= 2;

---
以上,希望对你有所帮助。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2009-07-08
1. select * from Course a where a.teacher = 'Liu';
2. select * from Student a where a.ssex = '女' and a.sage < 22;
3. select a.sname from student a, sc b, course c where a.sno = b.sno and b.cno = c.cno and c.teacher = 'Liu';
4. select a.sname from student a, sc b, course c where a.sno = b.sno and b.cno = c.cno and c.grade > 90 and b.cname = '程序设计';
5. select a.sname from student a, sc b, course c where a.sno = b.sno and b.cno = c.cno and b.cno != 'C3';
6. 这道题意思不明,C1 和 C2 是要同时满足吗?
相似回答