SQL Joins Explained with Practical Examples
Learn SQL joins through practical examples, including INNER JOIN, LEFT JOIN, RIGHT JOIN and FULL OUTER JOIN.

Most useful business questions span more than one table. A customer table might hold names, while an orders table stores purchases. SQL joins connect those records through a shared key, so you can analyze them together without losing the structure of the original data.
Start with two related tables
Imagine a customers table and an orders table. Both contain customer_id, so that shared value can connect each order to the person who placed it.
customers
customer_id | customer_name
------------|--------------
1 | Asha
2 | Ravi
3 | Mina
orders
order_id | customer_id | amount
---------|-------------|-------
101 | 1 | 45.00
102 | 1 | 18.00
103 | 3 | 72.00INNER JOIN: only matching records
An INNER JOIN returns rows that have a match in both tables. In this example, customers without an order are left out, and each order appears beside its customer’s name.
SELECT c.customer_name, o.order_id, o.amount
FROM customers AS c
INNER JOIN orders AS o
ON c.customer_id = o.customer_id;LEFT JOIN: keep every row from the left table
A LEFT JOIN keeps every customer, even when there is no matching order. Columns from orders are NULL for customers who have not purchased—useful for finding inactive customers or measuring adoption.
SELECT c.customer_name, o.order_id, o.amount
FROM customers AS c
LEFT JOIN orders AS o
ON c.customer_id = o.customer_id;RIGHT JOIN: keep every row from the right table
A RIGHT JOIN keeps every row from the right-hand table and adds matching values from the left. It can be useful when the right-side records must never be dropped, though many teams rewrite it as a LEFT JOIN by swapping the table order for readability.
SELECT c.customer_name, o.order_id, o.amount
FROM customers AS c
RIGHT JOIN orders AS o
ON c.customer_id = o.customer_id;FULL OUTER JOIN: keep matches and non-matches
A FULL OUTER JOIN keeps all rows from both tables. Matching records are combined; unmatched rows from either side remain, with NULL values where no partner exists. This is especially helpful when reconciling two lists.
SELECT c.customer_name, o.order_id, o.amount
FROM customers AS c
FULL OUTER JOIN orders AS o
ON c.customer_id = o.customer_id;Choose the join that matches the question
Before writing a join, decide which records must remain in the result. INNER JOIN keeps matches only; LEFT and RIGHT JOIN preserve one chosen side; FULL OUTER JOIN preserves both. Then confirm the join key is unique where expected, because duplicate keys can multiply rows and inflate totals.
A quick row-count check and a few manually verified records can catch many join mistakes before they reach a dashboard or report.