🔗 INNER JOIN in SQL
Last Updated: 7th January 2026
The INNER JOIN returns only those rows that have matching values in both tables. If a row does not match, it is excluded from the result.
Think like this:
- Table A has some rows
- Table B has some rows
- INNER JOIN keeps only the common part
Hinglish Tip 🗣: Dono tables me match hone wali rows hi chahiye →
INNER JOIN.
🧾 Basic Syntax
SELECT columns
FROM table1
INNER JOIN table2
ON table1.common_column = table2.common_column;
Notes:
INNERkeyword is optionalJOINalone meansINNER JOIN
📄 Example Tables
students
| student_id | name |
|---|---|
| 1 | Rahul |
| 2 | Anjali |
| 3 | Aman |
enrollments
| student_id | course |
|---|---|
| 1 | SQL |
| 3 | Python |
| 4 | Java |
📄 INNER JOIN Example
SELECT students.name, enrollments.course
FROM students
INNER JOIN enrollments
ON students.student_id = enrollments.student_id;
✅ Result
| name | course |
|---|---|
| Rahul | SQL |
| Aman | Python |
Explanation:
student_id = 2→ no match → excludedstudent_id = 4→ exists only in enrollments → excluded
🔄 INNER JOIN with WHERE
SELECT s.name, e.course
FROM students s
INNER JOIN enrollments e
ON s.student_id = e.student_id
WHERE e.course = 'SQL';
Execution order:
- FROM + JOIN
- ON condition
- WHERE
- SELECT
Multiple Joins
- You can have multiple joins in a single query
- You can have multiple tables in a single join
SELECT s.name, e.course
FROM students s
INNER JOIN enrollments e
ON s.student_id = e.student_id
INNER JOIN courses c
ON e.course_id = c.course_id;
Explanation:
s=studentse=enrollmentsc=coursese.course_id=c.course_ideis the common table betweensandctables
Inner Joins Using USING Keyword
- It is helpful when you have identical column names in both tables
- You can pass multiple identical column names to
USINGkeyword
SELECT s.name, e.course
FROM students s
INNER JOIN enrollments e
USING (student_id);
Hinglish Tip 🗣:
USINGkeyword ke saathONkeyword nahi lagta hai.