Search⌘ K

INNER JOIN of Tables

Learn how to join multiple tables in SQL.

Step 1: Start with a question

Until now, you’ve worked with one table, like employees. But in most real databases, information is spread across multiple tables that share something in common.

Let’s imagine two tables:

  • employees contains employee_id, name, department_id(notice this is not department name), salary

  • departments contains department_id, department_name

You might ask: How can I see each employee’s name along with their department name?

That’s where joins come in.

Prompt: Write a SQL query that shows each employee’s name and their department name by joining the employees and ...