NATURAL JOINs

SELECT with a NATURAL INNER JOIN

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;
Run in terminal

The query should return 76 rows.

SELECT with a NATURAL LEFT JOIN

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;
Run in terminal

The query should return 91 rows.

SELECT with a NATURAL RIGHT JOIN

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;
Run in terminal

The query should return 89 rows.