欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

SQL JOIN

程序员文章站 2022-05-09 15:58:39
...

SQL JOIN

 

stud:

SQL JOIN

Course:

SQL JOIN

stud_crs:

SQL JOIN

 

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:

SQL JOIN

 

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:

SQL JOIN

 

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:

SQL JOIN

 

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:

SQL JOIN

 

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:

SQL JOIN

 

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:

SQL JOIN

 

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):

SQL JOIN

 

相关标签: notes