SQL JOIN
程序员文章站
2022-05-09 15:58:39
...
stud:
Course:
stud_crs:
select stud_crs.scno, stud.sno as 学号, stud.sname as 姓名, stud_crs.cno as 课程号, stud_crs.grade as 分数
from stud inner join stud_crs on stud.sno = stud_crs.sno;
A intersects B:
select stud_crs.scno, stud.sno as 学号, stud.sname as 姓名, stud_crs.cno as 课程号, stud_crs.grade as 分数
from stud left outer join stud_crs on stud.sno = stud_crs.sno;
A:
select stud_crs.scno, stud.sno as 学号, stud.sname as 姓名, stud_crs.cno as 课程号, stud_crs.grade as 分数
from stud right outer join stud_crs on stud.sno = stud_crs.sno;
B:
select stud_crs.scno, stud.sno as 学号, stud.sname as 姓名, stud_crs.cno as 课程号, stud_crs.grade as 分数
from stud full outer join stud_crs on stud.sno = stud_crs.sno;
A unions B:
select stud_crs.scno, stud.sno as 学号, stud.sname as 姓名, stud_crs.cno as 课程号, stud_crs.grade as 分数
from stud left outer join stud_crs on stud.sno = stud_crs.sno
where stud_crs.sno is null;
A - B:
select stud_crs.scno, stud.sno as 学号, stud.sname as 姓名, stud_crs.cno as 课程号, stud_crs.grade as 分数
from stud right outer join stud_crs on stud.sno = stud_crs.sno
where stud.sno is null;
B - A:
select stud_crs.scno, stud.sno as 学号, stud.sname as 姓名, stud_crs.cno as 课程号, stud_crs.grade as 分数
from stud full outer join stud_crs on stud.sno = stud_crs.sno
where stud.sno is null or stud_crs.sno is null;
(A unions B) - (A intersects B):
上一篇: 事务的隔离级别