🔍
👶 Kids📝 Blog About Contact 🚀 Get Started Free

SQL – Joins Overview

Understand how SQL joins combine rows from two or more tables using a matching condition.

When data is split across multiple tables, joins bring it back together. The fundamental idea: find rows in Table A and Table B where some column matches — usually a primary key and foreign key — and combine them into a single output row. Without joins, relational databases would be just a collection of isolated spreadsheets.

There are four main types of joins: INNER JOIN, LEFT JOIN, RIGHT JOIN, and FULL JOIN. Each answers a slightly different question about how to handle rows that have no match in the other table.

Join types at a glance

JoinReturns
INNER JOINOnly rows with matches in BOTH tables
LEFT JOINAll left rows + matching right rows
RIGHT JOINAll right rows + matching left rows
FULL JOINAll rows from both tables

Try It Yourself — Interactive SQL Editor

Edit the query below and click Run Query ▶ to see live results powered by SQLite running directly in your browser.

SQLite – edit & run
Results
← Click Run Query ▶ to see results

Key Points

  • Joins use a matching condition (ON clause) to link tables
  • The most common join is INNER JOIN (often written as just JOIN)
  • Always specify ON conditions — missing them cause cartesian products
  • Multiple joins can be chained in a single query

Pro Tip from CodesCompiler: The best way to learn SQL is to break things intentionally — modify the query above, change the WHERE conditions, try different columns. Every error teaches you something the docs cannot.

In the next lesson, we continue exploring SQL’s powerful feature set to build your database mastery.