What Is an Inner Join in SQL? How It Works and When It Matters

If you've spent any time working with relational databases, you've almost certainly encountered the INNER JOIN — one of the most fundamental and widely used SQL operations. Understanding exactly what it does, how it behaves, and where its behavior changes based on your data is essential for writing accurate, efficient queries.

The Core Concept: Matching Rows Across Tables

An INNER JOIN combines rows from two or more tables based on a related column they share. The result set includes only the rows where a matching value exists in both tables. If a row in one table has no corresponding match in the other, it's excluded entirely from the output.

Think of it like a Venn diagram — the INNER JOIN returns only the overlapping section in the middle.

Here's the basic syntax: