天天酷跑苹果充值:SQL查询语句

来源:百度文库 编辑:高校问答 时间:2024/04/29 17:34:25
Student(Sno,Sname,Sex,Age,Dept)
SC(Sno,Cno,Grade)
Course(Cno,Cname)
查询至少选修了课程号C1和C2课程的学生的学号。

Select Sno,C1 From SC Where Sno IN (Select Sno From SC Where Cno=C2)

Select Sno From Student Where Sno IN (Select Sno From SC Where Cno=C1 or Cno=C2)

建议尽量不要使用子查询,而尽量使用交叉查询
select student.sno from student,sc,course where student.sno=sc.sno and student.sno=course.sno and sc.cno=c1 and course.cno=c2
如果需要两门都必修就用and,否则就用or,你的course表缺少一个sno字段

select

电脑小虫 把QQ号留下