INNER JOIN
Return only rows that match in both tables
✅ What You Will Learn
INNER JOIN returns only the rows where the join condition matches in BOTH tables. If a row exists in the left table but has no match in the right table (or vice versa), it is excluded from the result.
This is the most commonly used JOIN in data analytics. Use it when you only want records that have complete information across both tables.
📋 customers table joined with orders table on customer_id
| customer_id | customer_name | city | order_id | product | amount |
|---|---|---|---|---|---|
| 1 | Rahul Sharma | Delhi | 1001 | Laptop | 45000 |
| 1 | Rahul Sharma | Delhi | 1003 | Headphones | 3500 |
| 2 | Priya Verma | Noida | 1002 | Mobile Phone | 18000 |
| 4 | Sneha Kapoor | Delhi | 1004 | Laptop | 52000 |
| 5 | Vikram Singh | Noida | 1005 | Tablet | 28000 |
Syntax
Examples
📌 Key Points to Remember
- ✓INNER JOIN only returns rows with a match in both tables
- ✓Rows without a match in either table are excluded
- ✓Always use table aliases (c, o) to keep queries readable
- ✓Use table.column notation (c.customer_name) when the same column name exists in both tables
- ✓JOIN first, filter with WHERE after, then GROUP BY
🏢 Real-World Application
INNER JOIN is the most common join in analytics. "Show each order with the customer name, city, and the product category" — that is an INNER JOIN between orders, customers, and products. At any data-driven company, a data analyst runs INNER JOINs to enrich transactional data with dimension data. Analysts at banks use INNER JOIN to link transaction records with customer KYC details. Analysts at logistics companies JOIN shipment records with warehouse location data. Mastering INNER JOIN unlocks the ability to answer cross-table business questions that are impossible with a single table.
⚠️ Common Mistakes to Avoid
❓ Frequently Asked Questions
What is INNER JOIN in SQL?
INNER JOIN returns rows where there is a matching value in both tables. Rows from either table that do not have a match in the other table are excluded from the result. It is the most commonly used join type.
What is the difference between JOIN and INNER JOIN?
They are identical. Writing JOIN without a type keyword defaults to INNER JOIN in all major databases. Best practice is to write INNER JOIN explicitly for clarity.
Can INNER JOIN return duplicate rows?
Yes. If the right table has multiple rows matching one row in the left table, the left row will appear multiple times in the result — once per match. This is correct behavior, not a bug.
How do I join three tables in SQL?
Chain multiple JOIN clauses: FROM orders o INNER JOIN customers c ON o.customer_id = c.customer_id INNER JOIN products p ON o.product_id = p.product_id. Each JOIN adds another table to the result.
What happens to non-matching rows in INNER JOIN?
They are discarded. If an order has a customer_id that does not exist in the customers table, that order row will not appear in the INNER JOIN result. Use LEFT JOIN to keep such rows.
✏️ Practice Exercise
Write a query to show customer name, city, and total amount spent — for customers from Noida only.
Learn SQL with Live Trainer Guidance
These tutorials give you the theory. Our live SQL course at EVIKA Academy, Noida teaches you to apply SQL on real company datasets — with a trainer who uses it daily at MakeMyTrip.