Course contentsShow
← Data Science
Lesson 918 of 2,14524. SQL JoinsFree lesson

What is an INNER JOIN?

Learn how INNER JOIN combines rows from two tables based on a matching condition, returning only matched pairs.

What is an INNER JOIN?

You'll learn how to combine data from two tables by matching rows that share common values.

The Core Idea

An INNER JOIN is SQL's way of bringing together information from two separate tables based on a relationship between them. Think of it like matching puzzle pieces: only the pieces that fit together (share matching values in specified columns) appear in your result.

Imagine you have two lists:

  • Customers table: customer ID, name, email
  • Orders table: order ID, customer ID, order amount

An INNER JOIN lets you connect these tables through the common "customer ID" column. The result? You get rows showing customer details alongside their order information — but only for customers who have actually placed orders.

How It Works

The INNER JOIN examines each row from the first table and checks if there's a matching value in the second table's join column. When a match is found, it combines those rows into a single result row. If no match exists, that row is excluded from the results entirely.

This "only matched pairs" behavior is what makes it an INNER join — you only see the intersection of both tables, not everything from either side.

Real-World Analogy

Think of a school dance where students must present matching tickets to enter together. An INNER JOIN is like the list of couples who successfully paired up and got in. Students without matching partners don't appear on this list at all.

Why It Matters

Most business questions require combining data from multiple tables: "Which customers bought what products?" or "How many orders did each employee process?" INNER JOINs are your fundamental tool for answering these questions.

Key Takeaway: An INNER JOIN returns only the rows where matching values exist in both tables, creating a combined result set from successfully paired records.