Skip to content

INNER JOIN

In one line

INNER JOIN returns only the rows where the join condition matches in both tables — non-matching rows are excluded.

In simple words

INNER JOIN is the most common join type. It returns only rows that have a match in both tables. If a row in the left table has no matching row in the right table (or vice versa), it is excluded from the result.

For example, if you join orders to users with INNER JOIN, you get only orders that have a matching user. If an order has a user_id that does not exist in users (should not happen with proper foreign keys), that order would be excluded.

INNER JOIN is symmetric — A INNER JOIN B gives the same result as B INNER JOIN A. It is the default join type, so you can write just JOIN.

Example

sql
-- Only orders with a matching user
SELECT orders.id, users.name
FROM orders
INNER JOIN users ON orders.user_id = users.id;

Returns rows only where a matching user exists for the order.

Related terms

Related Resources

Related Lessons

  • Joins

    Learn different join types.

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary