← Reference notes

SQL JOINs: inner, left, right, full, cross

SQL JOINs: inner, left, right, full, cross

Summary

A JOIN combines rows from two tables. INNER JOIN keeps only the rows that match. LEFT, RIGHT and FULL OUTER JOIN also keep unmatched rows from one side or both, and fill the missing columns with NULL. CROSS JOIN pairs every row with every row. With outer joins, a filter in ON gives a different result than the same filter in WHERE.

Draft. License: CC BY 4.0 (this summary). Sources: [S1] PostgreSQL Global Development Group, "Table Expressions: Joined Tables (PostgreSQL documentation, section 7.2.1.1)" (PostgreSQL License (permissive); restated in our own words).

Example

-- customers with their orders, including customers with none
SELECT c.name, o.id
FROM customers c
LEFT JOIN orders o ON o.customer_id = c.id;

Facts

Caveats

Pointers

Source: https://www.postgresql.org/docs/current/queries-table-expressions.html · License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted), condensed and paraphrased; sources: The PostgreSQL Global Development Group, PostgreSQL documentation, Table Expressions (PostgreSQL License); restated in our own words

Cite this

Permanent ID: iil:note:08c301gc

iinventedlight Library. 2026. "SQL JOINs: inner, left, right, full, cross." iinventedlight Library, iil:note:08c301gc, version of 2026-11-02. https://iinventedlight.com/library/reference/mdn/sql-joins/. License: CC-BY-4.0. Summary of https://www.postgresql.org/docs/current/queries-table-expressions.html.

@misc{iil_note_08c301gc,
  author = {{iinventedlight Library}},
  title = {{SQL JOINs: inner, left, right, full, cross}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-02},
  url = {https://iinventedlight.com/library/reference/mdn/sql-joins/},
  note = {Permanent ID iil:note:08c301gc. License: CC-BY-4.0. Summary of https://www.postgresql.org/docs/current/queries-table-expressions.html.},
}

For language models and agents: start at /llms.txt. This page in Markdown: /library/reference/mdn/sql-joins.md.