The INNER JOIN is the most common join in database computing. It queries records from two or more tables and returns only the rows that satisfy the join condition in both tables. Any unmatched records on either side are completely omitted from the result set.
SELECT a.column1, b.column2
FROM table_a a
INNER JOIN table_b b ON a.key = b.key;
-- Join students and departments on dept_id
SELECT
s.student_id,
s.first_name,
d.dept_name,
s.gpa
FROM students s
INNER JOIN departments d ON s.dept_id = d.dept_id;
| student_id | first_name | dept_name | gpa |
|---|---|---|---|
| 1 | Aman | Engineering | 3.85 |
| 2 | Pooja | Business | 3.92 |
| 3 | Rohan | Engineering | 3.75 |
NULL dept_id) is excluded because NULL matches nothing.Next, let us learn how to keep all rows from the primary table using SQL LEFT OUTER JOIN!
An INNER JOIN excludes any row from Table A that has no match in Table B, as well as any row from Table B that has no match in Table A. Only mutual matches are included.
They are completely identical! In standard ANSI SQL, writing 'JOIN' defaults to an INNER JOIN.
Yes! You can chain multiple JOIN ... ON clauses together to connect three, four, or more related tables (e.g., students -> enrollments -> courses -> professors).
Proceed to the next class in sequence to build production mastery of relational database architecture.
Continue to Class 35: LEFT JOIN → Previous: ← Joins Overview | Full Syllabus
Relational algebra principles of inner and outer joins.
Comparing inner join with outer joins that preserve unmatched rows.
Joining tables without ON clauses and self-referencing joins.
How B-tree indexes turn O(N^2) joins into O(N log N) speed.