SQL JOINs Cheatsheet

Visual Venn diagram reference for all SQL JOIN types with copy-paste examples

A SQL JOIN combines rows from two or more tables based on a related column. Understanding each JOIN type — from INNER to anti-JOINs — lets you query exactly the data you need. Use this visual cheatsheet to find the right JOIN for any scenario.

Dialect:

Showing 9 JOIN types

How to Use the SQL JOINs Cheatsheet

SQL JOINs are the backbone of relational databases — they let you combine data from multiple tables into a single result set. Knowing when to use each SQL JOIN type is one of the most important skills in writing efficient queries.

Step 1: Browse or search JOIN types

All 9 JOIN types are displayed as cards. Use the search bar to filter by name or keyword (e.g., type "outer" to see all outer JOINs). Use the category tabs to narrow to Standard, Anti-JOINs, or Special JOINs.

Step 2: Read the Venn diagram

Each card includes a Venn diagram showing which data is returned — the filled (highlighted) region represents the rows included in the result set. Two filled circles means all rows from both tables; one filled circle means only rows from that side; the intersection filled means only matching rows.

Step 3: Copy the SQL example

Each card shows a formatted SQL example using employees and departments sample tables. Click the Copy button on any code block to instantly copy it to your clipboard. The syntax highlighting makes the query structure easy to read at a glance.

Step 4: Switch SQL dialects

Use the Dialect toggle at the top to switch between PostgreSQL, MySQL, and SQL Server. Notes about dialect-specific differences (such as MySQL's lack of FULL OUTER JOIN support) are shown inline where relevant.

Quick reference: which JOIN to use?

  • INNER JOIN — you need only rows that exist in both tables (e.g., orders with a valid customer)
  • LEFT JOIN — you need all rows from the primary (left) table, even if there is no match (e.g., all customers, whether or not they have orders)
  • RIGHT JOIN — you need all rows from the secondary (right) table (less common; usually rewrite as a LEFT JOIN)
  • FULL OUTER JOIN — you need all rows from both tables, with NULLs where there is no match
  • LEFT ANTI JOIN — you need rows from the left table that have no match in the right (e.g., customers who have never ordered)
  • CROSS JOIN — you need every possible combination of rows from two tables (e.g., product sizes × colors)
  • SELF JOIN — your table references itself (e.g., employee–manager hierarchy)

Frequently Asked Questions

Is this SQL JOINs cheatsheet free?

Yes, completely free with no account or signup required. All JOIN types, examples, and copy buttons are available instantly in your browser.

Is my data safe when using this tool?

Yes. This cheatsheet runs entirely in your browser — no data is sent to any server. Your searches and activity are completely private.

What is the difference between INNER JOIN and LEFT JOIN?

INNER JOIN returns only rows where there is a match in both tables. LEFT JOIN returns all rows from the left table plus matching rows from the right — if there is no match on the right, the columns from the right table are filled with NULL.

What is a LEFT ANTI JOIN and when should I use it?

A LEFT ANTI JOIN returns rows from the left table that have NO matching row in the right table. You write it as a LEFT JOIN with a WHERE right_table.id IS NULL condition. Use it to find records that are missing a relationship — for example, customers who have never placed an order.

Does MySQL support FULL OUTER JOIN?

No, MySQL and MariaDB do not natively support FULL OUTER JOIN. You can emulate it by doing a LEFT JOIN UNION ALL RIGHT JOIN WHERE left.id IS NULL. PostgreSQL and SQL Server both support FULL OUTER JOIN natively.

What is a CROSS JOIN and when should I use it?

A CROSS JOIN produces a cartesian product — every row from the left table is combined with every row from the right table. If each table has 5 rows, you get 25 result rows. Use it for generating combinations, seeding test data, or pairing every item with every other item (like sizes and colors for a product matrix).

What is a SELF JOIN and why would I use it?

A SELF JOIN joins a table to itself, using table aliases to distinguish the two copies. Use it when rows in a table reference other rows in the same table — for example, an employees table where each employee has a manager_id that points to another employee in the same table.

What is the difference between LEFT JOIN and LEFT OUTER JOIN?

They are identical. The word OUTER is optional in standard SQL and most databases. LEFT JOIN and LEFT OUTER JOIN produce exactly the same result. The same applies to RIGHT JOIN vs RIGHT OUTER JOIN and FULL JOIN vs FULL OUTER JOIN.