INNER JOIN of Tables
Explore how to use INNER JOIN to link related tables by their keys in SQL. Learn to write queries that combine employee and department data, understand why unmatched records are excluded, and practice expanding queries to include additional fields. This lesson will help you confidently connect tables and derive richer insights from your database.
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:
employeescontainsemployee_id,name,department_id(notice this is not department name),salarydepartmentscontainsdepartment_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 ...