对于教学数据库的三个基本表: S(S#,SNAME,AGE,SEX) SC(S#,C#,GRADE) C(C#,CNAME,TEACHER) 试用SQL的查询语句表达下列查询: 1)检索LIU老师所讲授课程的课程号。 2)检索年龄小于20岁的女学生的学号和姓名。 3)检索学号为S1的学生所学课程的课程名与任课教师名。 4)检索LI同学不学的课程的课程号。 5)检索至少选修四门课程的学生学号。 6)求选修C2课程的男学生的平均成绩。 7)检索学号比WANG同学小,而年龄比他大的学生姓名。 8)检索姓名以M打头的所有学生的姓名和年龄。 9)在表SC中检索成绩为空值的学生学号和课程号。 10)把ENGLISH课不及格的成绩全改为60分。
1)select c# from c where teacher=’liu’ 2)select s#,sname from student where age<20 and sex=’女’ 3)select cname,teacher from sc,c where sc.c#=c.c# and s#=’s1’ 4)select c# from c where c# not in (select c# from s,sc where s.s#=sc.s# and sname=’LI’) 5)select s# from sc group by s# having count(*)>=4 6)select avg(grade) from sc,s where s.s#=sc.s# and sex=’男’and c#=’c2’ 7)select sname from s where s#<(select s# from s where sname=’WANG’) and age>(select age from s where sname=’WANG’) 8)select sname,age from s where sname like ‘M%’ 9)select s#,c# from sc where grade is null 10)update sc set grade=60 where s# in (select s# from c,sc where c.c#=sc.c# and cname=’ENGLISH’ and grade<60)