Skip to content
BENIBIX Learn

Inner Join

Development🗃️ DatabasesRelational Databases

Also known as INNER JOIN

A join that keeps only the rows with a match in both tables.

Think of it like

Think of it like a dance where only pairs get on the floor. Anyone without a partner sits out.

Example

Jack lists customers who have bought something. Lucy has no orders yet, so the inner join leaves her out.

Why it matters

Most questions are about things that are linked. An inner join gives exactly those.

Definition

An inner join returns only the rows that have a match in both tables. A customer with no orders does not appear, and neither does an order with no customer. It is the default kind of join, so a plain JOIN means INNER JOIN. Use it when you only care about things that are linked. It is the most common join by far.

Example code

sql
SELECT customers.name, orders.total
FROM customers
INNER JOIN orders ON orders.customer_id = customers.id;
-- Emma | 25.0
-- Emma | 40.0
-- Jack | 15.5
Lucy has no orders, so she is not in the result.

Common mistake

Using an inner join when you need the rows with no match too. They vanish without any warning.

Key takeaways

  1. 1
    Matches only. Both sides must have a row.
  2. 2
    The default. Plain JOIN means inner.
  3. 3
    Silent drops. Rows with no match just vanish.

Compare