姓名表a
id name 1 张三 2 李四 3 王五
工作表b
id job Sid 1 23 1 2 34 2 3 34 4
姓名表的id和工作表的sid是主外键关系
(1) 内连接: select a.*,b.* from a inner join b on a.id=b.sid
结果:
a.id a.name b.id b.job b.sid
1 张三 1 23 1 2 李四 2 34 2
(2) 左连接: select a.*,b.* from a left join b on a.id=b.sid
结果:
a.id a.name b.id b.job b.sid 1 张三 1 23 1 2 李四 2 34 2 3 王五 null
3) 右连接: select a.*,b.* from a right join b on a.id=b.sid
结果:
a.id a.name b.id
b.jobb.sid 1 张三 1 23 1 2 李四 2 34 2 null 3 34 4
4) 完全连接:select a.*,b.* from a full join b on a.id=b.parent_id
结果:
a.id a.name b.id b.job b.sid 1 张三 1 23 1 2 李四 2 34 2 null 3 34 4 3 王五 null