INNER JOIN
INNER JOIN keeps only matching rows
INNER JOIN returns only row combinations for which the ON condition is satisfied. If a row from one table has no matching row in the other table, it is excluded from the result.
SELECT o.id, u.name
FROM orders AS o
INNER JOIN users AS u ON u.id = o.user_id;
If an order refers to an existing user, the rows are combined. If no match exists, that order does not appear in the result of this join.
JOIN usually means INNER JOIN
In many queries, the word INNER is omitted: JOIN users ... is normally equivalent to INNER JOIN users ....
INNER JOIN answers the question “where is there a match on both sides?”
If rows without a match must be preserved, you need an outer join, which we will cover next.
Check yourself
Exercise review
The mentor knows the solution and will help you reach it independently
Sign in to use the Mentor
The Mentor uses the current exercise and your conversation history.
Sign in
Review the key nuances and the answer after making your own attempt.
Sign in to view the solution
The solution and explanation are available after signing in.
Sign in