community/learn/content/01-SQL-Basics/03-joins/05-natural-join.md
In this exercise we will query the products table using a NATURAL INNER JOIN with the order_details table.
SELECT DISTINCT products.product_id,
products.product_name,
order_details.unit_price
FROM products
NATURAL INNER JOIN order_details
ORDER BY products.product_id;
The query should return 76 rows.
In this exercise we will query the customers table using a NATURAL LEFT JOIN with the orders table.
SELECT DISTINCT customers.customer_id,
customers.contact_name,
orders.ship_region
FROM customers NATURAL
LEFT JOIN orders
ORDER BY customers.customer_id DESC;
The query should return 91 rows.
In this exercise we will query the customers table using a NATURAL RIGHT JOIN with the orders table.
SELECT DISTINCT customers.company_name,
customers.contact_name,
orders.ship_region
FROM customers NATURAL
RIGHT JOIN orders
ORDER BY company_name DESC;
The query should return 89 rows.