「Postgresql入門」RIGHT(LEFT) OUTER JOINでテーブル結合サンプル

1.RIGHT OUTER JOINでの外部結合

SELECT
T1.*,
T2.NAME NM_CFT
FROM
CARS T1
RIGHT OUTER JOIN COMPANY T2
ON T2.ID = T1.PRODUCT_ID
LEFT OUTER JOIN HOME T3
ON T3.ID = T1.PRODUCT_ID
AND T3.ID_MANAGE = T1.MANAGE;

2.LEFT OUTER JOINでの外部結合

SELECT
T1.* ,
T2.NAME NM_CFT
FROM
CARS T1
LEFT OUTER JOIN COMPANY T2
ON T2.ID = T1.PRODUCT_ID
LEFT OUTER JOIN HOME T3
ON T3.ID = T1.PRODUCT_ID
AND T3.ID_MANAGE = T1.MANAGE;

Comments are closed.