Inner Join in SQL: How It Works

Estimated study time: 6 minutes. The most commonly used join in SQL.

An INNER JOIN combines rows from two tables based on a related column, returning only the rows where a match exists in both tables. It's the join you'll reach for most often.

Basic Syntax

SELECT columns
FROM TableA
INNER JOIN TableB ON TableA.key = TableB.key;

A Practical Example

SELECT Employees.EmpName, Departments.DeptName
FROM Employees
INNER JOIN Departments ON Employees.DeptID = Departments.DeptID;

This returns every employee that has a matching department — an employee with a DeptID that doesn't exist in Departments (or is NULL) is left out entirely.

How It Actually Works

Conceptually, SQL Server compares every row of the first table against every row of the second table (though the actual execution plan is usually far smarter than a brute-force loop), keeping only pairs where the join condition evaluates to true.

Joining More Than Two Tables

You can chain multiple INNER JOINs to pull data from several related tables at once:

SELECT e.EmpName, d.DeptName, p.ProjectName
FROM Employees e
INNER JOIN Departments d ON e.DeptID = d.DeptID
INNER JOIN Projects p ON e.EmpID = p.LeadEmpID;
💡 Tip: INNER JOIN is the default — writing plain JOIN in SQL Server is treated exactly the same as INNER JOIN.

INNER JOIN vs Other Joins

Unlike a LEFT JOIN or RIGHT JOIN, an INNER JOIN never fills in NULLs for unmatched rows — it simply excludes them from the result. If you need unmatched rows preserved, an outer join is the right tool instead.

Ready to go beyond the basics?

Get hands-on training, live mentorship, and placement support with Uncodemy's Data Analytics Course.

Explore Data Analytics Course →