有三个表,格式如下:
students(学生表): sno(学号) sname(名字) sex(性别) sage(年龄) sdept(系别)
Enrollement(课程表):sno(学号) cno(选课) grade(成绩)
Courses(选课表) :cno(选课) cname(课程名) credits(学分)
要求:查询计算机系选修了课程名为Database并且成绩大于90分的学生的学号。
我学SQL还不到一个星期,请问各位大虾,我写的两种方法正确么?
select sno
from students,enrollment,courses
where sdept ='computer' and sno in (select sno from enrollment where grade>90
and cno in (select cno from courses where cname=‘database’))
或者
select sno
from students,enrollment,course
where students.sno=enrollment.sno and courses.cno=enrollment.cno
and sdept='computer' and cname='database' and grade>90