–连接查询----查询学生及其选修课情况
select 学号+student
.,学号sc.
from 学号+student
,学号sc
where学号+student
.sno=学号sc.sno;
–自身链接–查询每一门课的间接先修课select FIRST.cno,SECOND.cpnofrom 学号course first, 学号course second where FIRST.cpno=SECOND.cno;
–查询同时选修1号课程和2号课程学生学号select a.snofrom 学号sc a,学号sc bwhere a.sno=b.sno and a.cno='001’and b.cno=‘003’;
–查询和张力在一个系的学生的姓名和学号select b.sno,b.sname,b.sdeptfrom 学号+student
a,学号+student
bwhere a.sdept=b.sdept and a.sname=‘张丽’ and b.sname!=‘张丽’;
–外连接–查询 所有 学生及其选修课程的情况select 学号+student
.*,学号sc.*from 学号+student
right join 学号scon 学号+student
.sno=学号sc.sno;
–查询所有课的间接先修课select FIRST.cno,SECOND.cpnofrom 学号course FIRST LEFT JOIN 学号course SECOND on FIRST.cpno=SECOND.cno;
–查询每个学生学号,姓名,选修课程及成绩select 学号+student
.sno,sname,cname,gradefrom 学号+student
,学号course,学号scwhere 学号+student
.sno=学号sc.sno and 学号course.cno=学号sc.cno;
–between AND
–查询每个学生选修成绩的对应等级 有一定范围