Ad space (banner)
🗄️SQL Lessons
Lesson 16 / 50

INNER JOIN vs. LEFT JOIN

This lesson covers the difference between INNER JOIN and LEFT JOIN, so you can choose the right one for the job. It's for anyone searching "SQL INNER JOIN vs LEFT JOIN."

INNER JOIN keeps only rows that have a match in both tables. LEFT JOIN keeps every row from the left table, filling in NULL where there's no match on the right.

The example uses LEFT JOIN so Bob — who has no loan records — still shows up in the results. If INNER JOIN were used instead, Bob would simply be excluded; compare the two directly to see the difference in action.

A common early mistake is picking the wrong JOIN type for the situation. Ask yourself upfront: "do I only want rows that have a match, or do I want every row from the main table regardless?" If you want a full roster including students who've never borrowed a book, LEFT JOIN is the one you need — choosing incorrectly quietly drops data you actually wanted to see.

SQL
OUTPUT

💡 The SQL engine may take a few seconds to load the first time you run code.

Ad space (banner)
Ad space (in-article)