🔗 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:
- INNER keyword is optional
- JOIN alone means INNER JOIN
📄 Example Tables
students
enrollments
📄 INNER JOIN Example
SELECT students.name, enrollments.course
FROM students
INNER JOIN enrollments
ON students.student_id = enrollments.student_id;
Result
Explanation:
- student_id = 2 → no match → excluded
- student_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 = students
- e = enrollments
- c = courses
- e.course_id = c.course_id
- e is the common table between s and c tables
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 USING keyword
SELECT s.name, e.course
FROM students s
INNER JOIN enrollments e
USING (student_id);
Hinglish Tip 🗣: USING keyword ke saath ON keyword nahi lagta hai.
