问一道SQL数据库的考试题,很初级的

来源:百度知道 编辑:UC知道 时间:2024/06/21 05:09:04
明天补考要用,知道题也不会做,来求救
明天就要用,过了今晚答了也没用了= =;

已知
student(sno,sname,sex,age,class)
course(cno,cname,tno)
score(sno,cno,grade)
请查询 选修:C2 总成绩在60~80之间学生的学号,课程号,成绩
我是替人问的,她也说不清楚
C2是课程号,其他含义应该挺好猜的吧

如果C2是课程号如下
select * from score where grade>=60 and grade<=80 and cno='C2'
如果C2是课程名如下
select * from score a, where grade>=60 and grade<=80 and cno=(select cno from course where cname='C2')

每个字段是什么 意思你都不解释下??
select sno,cno,grade
from score left join course on score.cno=course.cno
where cname='c2' and grade between 60 and 80

select b.sno 学号,a.cno 课程号,b.grade 成绩 from course a,score b where a.cno=b.cno
and b.cname='C2'
and grade between 60 and 80
-------------------补充--------------------

和第一个表没啥关系,因为不从第一个表里取东西,只用第二个和第三个就可以了,写的挺明白了,她看了也能懂的吧

select * from score where grade>=60 and grade<=80 and cno='C2'

我觉得这个是对的,就是不知道格式是不是规范,考试对这些小地方也会扣分

我是楼主马甲

例、请查询选修了C2课程的所有学生 的学号和姓名。
SELECT s.sno,s.sname
FROM s,sc
where s.sno=sc.sno and sc.cno=“C2”;
SELECT sno, sname
FROM s where sno IN( SELECT