Back to results for “Joins”
SQL Server › Joins

What is an INNER JOIN, and how does it combine data from two tables?

Beginner

Answer

An INNER JOIN combines rows from two tables based on a matching condition, returning only the rows where a match is found in both tables, meaning any row without a corresponding match in the other table is simply left out of the results entirely.
SELECT o.OrderId, c.Name
FROM Orders o
INNER JOIN Customers c ON o.CustomerId = c.CustomerId;
Real-world example An order report combines order details with customer names using an INNER JOIN, showing only orders that are linked to an actual existing customer record, and excluding any orphaned data if it somehow existed.

Common follow-ups: What happens to rows that do not have a match when using an INNER JOIN?;Can you join more than two tables together in a single query?