INNER JOIN

A join matches rows in one table to rows in another, using a condition that is almost always a foreign key meeting a primary key.

JOIN on its own means INNER JOIN: only rows with a match on both sides survive.

Try it

Count the rows. Then count the books table on its own. Every book has an author here, so the numbers match, which will not always be true.

loading editor…
real SQLite, in your browser

Aliases b and a keep it readable. Once two tables are involved, qualifying every column with its table saves you from ambiguity errors later.

✦ An inner join silently drops the unmatched

Bessie Head is in authors and has no books, so she does not appear above. A book with a NULL author_id would vanish the same way. Nothing warns you: the query succeeds and the answer is quietly incomplete. When a count comes back lower than expected, this is the first thing to check.

Mark this lesson complete

Signed in, your progress follows you to every device.

Next: Joins Multiply Rows →
← Back