III. Retrieving Data from Multiple Tables 08- Outer Join Between Multiple Tables

SELECT

c.customer_id as ‘Customer ID’,

c.first_name as ‘First Name’,

o.order_id as ‘Order ID’,

p.name as ‘Product Name’,

os.name as ‘Order Status’,

s.name as ‘Shipper Name’,

o.shipped_date ‘Shipped Date’

FROM customers C

LEFT OUTER JOIN orders O

ON c.customer_id = o.customer_id

LEFT OUTER JOIN order_items oi

ON o.order_id = oi.order_id

LEFT OUTER JOIN products P

ON oi.product_id = p.product_id

INNER JOIN shippers S

ON o.shipper_id = s.shipper_id

INNER JOIN order_statuses OS

ON o.status = os.order_status_id

ORDER BY c.customer_id

Cust ID First Name Order ID Product Name Order Status Shipper Name Shipped Date
2 Ines 7 Lettuce - Romaine, Heart Shipped Mraz, Renner and Nolan 23-09-2018
5 Clemmie 5 Pork - Bacon,back Peameal Shipped Satterfield LLC 26-08-2017
6 Elka 10 Foam Dinner Plate Shipped Schinner-Predovic 23-04-2018
6 Elka 10 Longan Shipped Schinner-Predovic 23-04-2018
7 Ilene 2 Foam Dinner Plate Shipped Mraz, Renner and Nolan 03-08-2018
7 Ilene 2 Brocolinni - Gaylan, Chinese Shipped Mraz, Renner and Nolan 03-08-2018
7 Ilene 2 Petit Baguette Shipped Mraz, Renner and Nolan 03-08-2018
10 Levy 9 Petit Baguette Shipped Hettinger LLC 06-07-2017