Back to Yugabyte Db

NATURAL JOINs

community/learn/content/01-SQL-Basics/03-joins/05-natural-join.md

2026.1.0.0-b291.1 KB
Original Source

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;

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;

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;

The query should return 89 rows.