community/learn/content/01-SQL-Basics/03-joins/02-outer-join.md
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_region
FROM customers
LEFT JOIN orders ON customers.region = orders.ship_region
ORDER BY company_name DESC;
The query should return 91 rows.
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_region
FROM customers
RIGHT OUTER JOIN orders ON customers.region = orders.ship_region
ORDER BY company_name DESC;
The query should return 33 rows.
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_region
FROM customers
FULL OUTER JOIN orders ON customers.region = orders.ship_region
ORDER BY company_name DESC;
The query should return 93 rows.
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_id
FROM employees
FULL OUTER JOIN orders ON employees.employee_id = orders.employee_id;
The query should return 464 rows.