A MySQL JOIN combines columns from two or more tables based on a related key column shared between them.
flowchart LR
A["Table A (Left)"] --- B["INNER JOIN (Matching Rows Only)"]
A --- C["LEFT JOIN (All Left + Matching Right)"]
D["Table B (Right)"] --- B
D --- E["RIGHT JOIN (All Right + Matching Left)"]
-- Query customer names alongside their orders
SELECT
c.first_name,
c.last_name,
o.order_id,
o.total_amount
FROM customers c
INNER JOIN orders o ON c.id = o.customer_id;
| first_name | last_name | order_id | total_amount |
|---|---|---|---|
| Jane | Doe | 1001 | 149.99 |
| Alice | Johnson | 1002 | 89.50 |
customer_id) are indexed to speed up table join lookups.c for customers, o for orders) for cleaner query readability.Which JOIN type returns all records from the left table even if there are no matching records in the right table?
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With