Loading Data Driven Insights
Preparing your learning content.
Preparing your learning content.
A beginner-friendly guide to using JOIN inside a SELECT query to read related data from multiple tables in SQL Server.
A JOIN is used inside a SELECT query to combine data from two or more related tables.
Instead of storing everything in one large table, databases usually split related information into separate tables. A JOIN helps bring that related information back together when you need to read it.
JOIN connects tables using related columns.
A basic join pattern looks like this.
SELECT
...
FROM Employees AS e
JOIN Departments AS d
ON e.department_id = d.department_id;
In SQL Server, JOIN by itself means INNER JOIN. It returns rows where the join condition matches in both tables.
Imagine you have two separate tables.
The Employees table stores employee details. The Departments table stores department details such as the department name and location.
To show each employee with their department location, SQL needs to connect both tables using a matching column.
employee_id
employee_name
department_id
department_id
department_name
location
We will join the Employees and Departments tables using department_id.
The ON condition tells SQL how the two tables are related.
In this example, Employees.department_id is matched with Departments.department_id.
SELECT
e.employee_name,
d.department_name,
d.location
FROM Employees AS e
INNER JOIN Departments AS d
ON e.department_id = d.department_id;
The ON condition tells SQL how the tables are related.
The result can now show employee information together with department information.
Use JOIN when the information you need is stored across separate but connected tables.
Learning SQL in order?
Use the roadmap to follow each SQL topic step by step, from relational database basics to advanced query techniques.
Back to SQL RoadmapRelated lessons
ALTER TABLE
A beginner-friendly guide to ALTER TABLE in SQL, including how to add, change, and remove columns from an existing table.
CREATE TABLE
A beginner-friendly guide to the SQL CREATE TABLE statement, including table planning, column names, data types, and a SQL Server-friendly example.
DELETE
A beginner-friendly guide to the SQL DELETE statement, with SQL Server-friendly examples for removing rows from a table safely.