Docs
Docs/JOINs & Relationships/Introduction to JOINs

Introduction to JOINs

Understand how tables relate to each other

JOINs combine rows from two or more tables based on related columns. They're fundamental to working with relational databases.

Why Use JOINs?

In relational databases, data is split across multiple tables to avoid duplication. JOINs reunite this data when you need it.

Example Tables

users

idnameemail
1Alicealice@mail.com
2Bobbob@mail.com
3Carolcarol@mail.com

orders

iduser_idtotal
1011$150
1021$75
1032$200

The Relationship

The user_id column in orders references the id column in users. This is called a foreign key relationship.

JOIN Types Overview

TypeReturns
INNER JOINOnly matching rows from both tables
LEFT JOINAll rows from left + matches from right
RIGHT JOINAll rows from right + matches from left
FULL OUTER JOINAll rows from both tables
CROSS JOINEvery combination (Cartesian product)

Note: JOIN without a prefix defaults to INNER JOIN.

Need help?

Join our Discord community for support and discussions.

Join Discord