下圖展示了 left join、right join、inner join、outer join 相關的 7 種用法。
具體分解如下:
1、inner join(內連線)
2、left join(左連線)
select from table_a a3、right join(右連線)left join table_b b
on a.key = b.key
select from table_a a4、outer join(外連線)right join table_b b
on a.key = b.key
select from table_a a5、left join excluding inner join(左連線-內連線)full outer join table_b b
on a.key = b.key
select from table_a a6.right join excluding inner join(右連線-內連線)left join table_b b
on a.key = b.key
where b.key is null
select from table_a a7、outer join excluding inner join(外連線-內連線)right join table_b b
on a.key = b.key
where a.key is null
select from table_a afull outer join table_b b
on a.key = b.key
where a.key is null or b.key is null
各種JOIN 用法
declare ta table id int,va varchar 10 declare tb table id int,vb varchar 10 insert into ta select 1,aa insert into ta select 2,bc insert into ta selec...
SQL 各種 join 的區別
參考 test ora1 sql select from a 編號 姓名 1000 張三 2000 李四 3000 王五 test ora1 sql select from b 編號 商品 1000 電視機 2000 錄影機 4000 自行車 test ora1 sql select a.b.fro...
sql的各種join連線
1 select from tablea inner join tableb 2 on tablea.name tableb.name 3id name id name 4 51 pirate 2 pirate 63 ninja 4 ninja78 9inner join 10產生的結果集中,是a和...