「SQL」left outer join左外部結合のサンプル
書式
select
カラム名
from テーブルA
left [outer] join テーブルB
on
結合条件
where
抽出条件
select
カラム名
from テーブルA
left [outer] join テーブルB
on
結合条件
where
抽出条件
select カラム名 from テーブルA left [outer] join テーブルB on 結合条件 where 抽出条件
使用例
select
aa.customername
, bb.orderid
from
customers aa
left join orders bb
on aa.customerid = bb.customerid
order by
aa.customername;
select
aa.customername
, bb.orderid
from
customers aa
left join orders bb
on aa.customerid = bb.customerid
order by
aa.customername;
select aa.customername , bb.orderid from customers aa left join orders bb on aa.customerid = bb.customerid order by aa.customername;