🔗 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 chahiyeINNER 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

student_idname
1Rahul
2Anjali
3Aman

enrollments

student_idcourse
1SQL
3Python
4Java

📄 INNER JOIN Example

SELECT students.name, enrollments.course
FROM students
INNER JOIN enrollments
ON students.student_id = enrollments.student_id;

✅ Result

namecourse
RahulSQL
AmanPython

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:

  1. FROM + JOIN
  2. ON condition
  3. WHERE
  4. 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.