SQL Join Types

Reference for all SQL JOIN types and their use cases.

The data

0

Type
INNER JOIN
Description
Returns rows where there is a match in both tables.
Syntax
SELECT * FROM a INNER JOIN b ON a.id = b.a_id

1

Type
LEFT JOIN
Description
Returns all rows from the left table and matched rows from the right.
Syntax
SELECT * FROM a LEFT JOIN b ON a.id = b.a_id

2

Type
RIGHT JOIN
Description
Returns all rows from the right table and matched rows from the left.
Syntax
SELECT * FROM a RIGHT JOIN b ON a.id = b.a_id

3

Type
FULL OUTER JOIN
Description
Returns all rows from both tables, with NULLs for non-matches.
Syntax
SELECT * FROM a FULL OUTER JOIN b ON a.id = b.a_id

4

Type
CROSS JOIN
Description
Returns the Cartesian product of both tables.
Syntax
SELECT * FROM a CROSS JOIN b

5

Type
SELF JOIN
Description
A table joined with itself. Useful for hierarchical data.
Syntax
SELECT * FROM employees e1 JOIN employees e2 ON e1.manager_id = e2.id

Fetch the same bytes

The static files are identical to what the API returns, but with no rate limit and no server round trip. Use the API when you want a query and a content type; use the files when you want to cache one document.

curl "https://yjtoon.com/api/dataset/sql-join-types?format=toon"
const res = await fetch(
  "https://yjtoon.com/static-data/dataset/sql-join-types.toon"
);
const toon = await res.text();

Rate limit: 120 requests per minute per IP, no key and no signup. API reference →

Topics

  • database
  • sql
  • joins
  • reference