OUTER JOIN
SELECT with a LEFT OUTER JOIN
In this exercise we will query the customers table using a LEFT JOIN with the orders table.
SELECT DISTINCT customers.company_name,customers.contact_name,orders.ship_regionFROM customersLEFT JOIN orders ON customers.region = orders.ship_regionORDER BY company_name DESC;Run in terminal
The query should return 91 rows.
SELECT with RIGHT OUTER JOIN
In this exercise we will query customers table using a FULL OUTER JOIN on orders.
SELECT DISTINCT customers.company_name,customers.contact_name,orders.ship_regionFROM customersRIGHT OUTER JOIN orders ON customers.region = orders.ship_regionORDER BY company_name DESC;Run in terminal
The query should return 33 rows.
SELECT with FULL OUTER JOIN
In this exercise we will query the customers table using a FULL OUTER JOIN with the orders table.
SELECT DISTINCT customers.company_name,customers.contact_name,orders.ship_regionFROM customersFULL OUTER JOIN orders ON customers.region = orders.ship_regionORDER BY company_name DESC;Run in terminal
The query should return 93 rows.
SELECT with FULL OUTER JOIN with only unique rows in both tables
In this exercise we will query the employees table using a FULL OUTER JOIN on the orders table using only the unique rows in each table.
SELECT DISTINCT employees.employee_id,employees.last_name,orders.customer_idFROM employeesFULL OUTER JOIN orders ON employees.employee_id = orders.employee_id;Run in terminal
The query should return 464 rows.