--Join链接
--内连接 inner join
--左外连接 left outer join
--left join
--表示 join左边的数据全显示出来,右边表的数据匹配的显示数据,不匹配的显示NULL
--left join 左边的表,就叫左表。
--请查询出那些没有参加考试的同学的stid ,姓名和年龄
--使用左查询的方法
select t1.stid,t1.stname,t1.stage
from Student as t1
left join TblScore as t2 on t1.stId=t2.tSid
where tEnglish is null and tMath is null
--使用内查询的方法
select * from Student
select * from TblScore
--先查出所有已经考试的人的ID
select stId,stname,stage
from student where stId not in
(select t1.stid
from Student as t1 inner join TblScore as t2
on t1.stId=t2.tSid)
SQL 内连接 左联接 右连接
猜你喜欢
转载自blog.csdn.net/BowenXu11/article/details/104730733
今日推荐
周排行