内连接
首先mysql内连接
select * from students inner join studescs on students.id=studescs.stuid
解释:
inner join表示两表交叉都拥有的数据,不会存在量表匹配不到的数据,如果匹配不到,不进行输出
左连接/右连结
select * from students left join studescs on students.id =studescs.stuid//左连接
select * from students right join students on students.id=studescs.stuid//右连接
解释:左右连接,是将左表或者右表进行全输出,而输出匹配到的右表或左表的数据
两表全输出
mysql不支持full
所以使用left join/right join +union
select * from students left join studescs on students.id =studescs.stuid union select * from students right join studescs on students.id=studescs.stuid