Skip to main content
Module 3 · Lesson 1 of 49/57 in the course~14 min
Module lessons (1/4)

Joining Two Tables: INNER JOIN

Lesson preview5 hands-on exercises readySQL Course · Module 3 — JOIN and GROUP BY

Combine matching rows across tables along primary and foreign keys.

What you'll learn in this lesson

  • Link two tables along the Primary Key ↔ Foreign Key relationship using INNER JOIN ... ON.
  • Always qualify ambiguous columns with short table aliases (e, d, b, a).
  • Understand why records with foreign key NULL are excluded from INNER JOIN.

Overview

In normalized relational databases, data lives in separate tables to avoid duplicates: employees stores department_id, while the department name lives in departments. INNER JOIN (abbreviated as JOIN) combines the rows of the two tables only when the condition ON is true.

Click the INNER vs LEFT buttons below to see how INNER JOIN retains only the central intersection excluding Diana (NULL) and Evan (FK orphan), as well as the empty Legal and Research departments:

Sections covered in this lesson

  1. 11. Mental Model: Intersection between Left and Right Table
  2. 22. Progressive & Annotated Examples
  3. 33. Interactive Lab: View the INNER JOIN
  4. 44. Diagnostic Verification (Quiz)
  5. 55. Progressive Practical Laboratory
Pro Lesson · Module 3 — JOIN and GROUP BY

Unlock "Joining Two Tables: INNER JOIN" and the full SQL Course curriculum

Combine matching rows across tables along primary and foreign keys.

Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in SQL Course plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.