← All Exercises

SQL INNER JOIN

basicsql~15min

Background

JOINs combine data from multiple tables by matching related columns, with INNER JOIN returning only matching rows.

Problem

Write a SQL query to join employees and departments tables to show employee names with their department names.

Input

employees table (id, name, department_id) and departments table (id, department_name).

Output

Employee names paired with their department names for employees that have a matching department.

Sample tests

Sample 1

Input: 3 employees, 2 departments, all employees have departments
Expected: 3 rows with name and department_name

Your solution

Learning objective

Learn INNER JOIN syntax, table aliases, and join conditions.