SQL Joins Explained
INNER, LEFT, RIGHT and FULL joins explained with diagrams and sample queries.
Why Joins Matter
Relational databases store data across multiple related tables to avoid duplication. Joins let you combine rows from two or more tables based on a related column, such as a customer ID, so you can query them together.
Inner Join
An INNER JOIN returns only the rows that have matching values in both tables.
SELECT o.order_id, c.customer_name, o.order_amount
FROM orders o
INNER JOIN customers c
ON o.customer_id = c.customer_id;
Left Join
A LEFT JOIN returns all rows from the left table, and matching rows from the right table. Unmatched right-side columns return NULL.
SELECT c.customer_name, o.order_id
FROM customers c
LEFT JOIN orders o
ON c.customer_id = o.customer_id;
Right Join
A RIGHT JOIN is the mirror of a left join — it returns all rows from the right table, and matching rows from the left table.
SELECT c.customer_name, o.order_id
FROM customers c
RIGHT JOIN orders o
ON c.customer_id = o.customer_id;
Full Join
A FULL JOIN returns all rows from both tables, matching where possible and filling unmatched sides with NULL.
SELECT c.customer_name, o.order_id
FROM customers c
FULL JOIN orders o
ON c.customer_id = o.customer_id;
Related Tutorials
Keep building your data engineering foundations.
How ETL Pipelines Work
A step-by-step walkthrough of Extract, Transform, Load with a practical example.
Read guide →Data Warehouse Basics
Learn the core building blocks of modern analytical warehouses.
Read guide →Python for Data Cleaning
Use pandas to handle missing values, duplicates, and inconsistent formats.
Read guide →