SQL · Pattern 6 — Joins
INNER JOIN
INNER JOIN returns only the rows where a matching value exists in both tables based on the join condition.
Source data — Pattern 6: Joins
All queries run against the shared employees and departments tables (see schema.sql). This pattern introduces the departments table. Topic 38 also needs a projects table, while topic 39 introduces a salary_grades table for non-equi joins.




What it does
INNER JOIN returns only the rows where a matching value exists in both tables based on the join condition. Rows without a match are excluded from the result.
Problem
Display employee names with department names.
SELECT e.first_name,
d.department_name
FROM employees e
INNER JOIN departments d
ON e.department_id = d.department_id;
Result
