# Join tables on a key

Join / keyed

inner, left, right, full join on equal keys

Page: <https://meridian.online/operations/join-tables-on-a-key>

## Status

Runs as a SQL step.

arcform carries it as a `sql:` step today.

## The DuckDB step

left join on a key

It reads the `orders` and `customers` tables the proofs share. Create them first:

```sql
CREATE TABLE orders AS SELECT * FROM (VALUES
  (1,  'Alice Ng',      'north', DATE '2026-01-03', 120.00, 'widget', 'a|b',   '{"channel":"web","items":[1,2]}'),
  (2,  'alice ng',      'north', DATE '2026-01-05',  80.50, 'gadget', 'b',     '{"channel":"shop","items":[3]}'),
  (3,  'Bob  Okafor',   'south', DATE '2026-01-05', 300.00, 'widget', 'a|c',   '{"channel":"web","items":[4,5,6]}'),
  (4,  'Carla Díaz',    'east',  DATE '2026-01-09',  NULL,  'gizmo',  NULL,    '{"channel":"web","items":[]}'),
  (5,  'Bob Okafor',    'south', DATE '2026-01-12',  45.25, 'gadget', 'c',     '{"channel":"phone","items":[7]}'),
  (6,  'Dev Patel',     'west',  DATE '2026-01-12', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (7,  'Carla Diaz',    'east',  DATE '2026-01-20',  99.99, 'gizmo',  'b|c',   '{"channel":"shop","items":[10]}'),
  (8,  'Dev Patel',     'west',  DATE '2026-02-02', 510.00, 'widget', 'a',     '{"channel":"web","items":[8,9]}'),
  (9,  'Eve Larsen',    NULL,    DATE '2026-02-03',  15.00, 'gadget', NULL,    '{"channel":"web","items":[11]}'),
  (10, 'Alice Ng',      'north', DATE '2026-02-10', 220.00, 'gizmo',  'a|b|c', '{"channel":"phone","items":[12,13]}')
) t(order_id, customer, region, order_date, amount, product, tags, meta);

CREATE TABLE customers AS SELECT * FROM (VALUES
  ('Alice Ng',    'retail',    DATE '2025-06-01', 52.52, 13.40),
  ('Bob Okafor',  'wholesale', DATE '2025-09-15', 48.85,  2.35),
  ('Carla Diaz',  'retail',    DATE '2025-11-30', 40.42, -3.70),
  ('Frank Moore', 'retail',    DATE '2026-01-01', 51.51, -0.13)
) t(customer, segment, joined, lat, lon);
```

Then run the statement:

```sql
CREATE TEMP TABLE result AS
SELECT o.order_id, o.customer, c.segment FROM orders o LEFT JOIN customers c USING (customer) ORDER BY o.order_id;
SELECT * FROM result;
SELECT CASE WHEN ((SELECT count(*) = 10 AND count(segment) = 4 AND max(segment) FILTER (WHERE order_id = 5) = 'wholesale' FROM result)) THEN 'as expected' ELSE error('the join did not keep 10 orders and match 4 of them') END AS verdict;
```

It needs nothing installed beyond DuckDB itself.

## Variants

- [Keep every row of both tables](https://meridian.online/operations/join-tables-on-a-key/keep-every-row-of-both-tables): Join on equal keys and keep every row of both tables, with nulls wherever either side has no match.
- Choose the join type: Join two tables on equal keys with one operator whose setting picks inner, left, right or full outer.
- Keep only matching rows: Join two tables on equal keys and keep only the rows whose key is found in both.
- [Join more than two tables](https://meridian.online/operations/join-tables-on-a-key/join-more-than-two-tables): Join three or more tables on their shared keys in one step.
- Join on shared column names: Join two tables on every column whose name they share, without naming the keys.
- [Nest the matching rows in a column](https://meridian.online/operations/join-tables-on-a-key/nest-the-matching-rows-in-a-column): Join on equal keys and put each row's matches from the other table into one nested-table column.
- [Keep every row of one table](https://meridian.online/operations/join-tables-on-a-key/keep-every-row-of-one-table): Join on equal keys and keep every row of the left or right table, with nulls where the other table has no match.

## What other tools call it

Meridian's classification; an independent blind rating agreed on 86.2% of 312 rows (exact class, version 2).

- Azure Data Factory: [`Join`](https://learn.microsoft.com/en-us/azure/data-factory/data-flow-join) (read 2026-09-27)
- Azure Data Factory: [`Merging/Joining tables`](https://learn.microsoft.com/en-us/azure/data-factory/wrangling-functions) (read 2026-09-27)
- Alteryx Designer: [`Calgary Join`](https://help.alteryx.com/current/en/designer/tools/calgary/calgary-join-tool.html) (read 2026-09-27)
- Alteryx Designer: [`Join`](https://help.alteryx.com/current/en/designer/tools/join/join-tool.html) (read 2026-09-27)
- Alteryx Designer: [`Join In-DB`](https://help.alteryx.com/current/en/designer/tools/in-database/join-in-db-tool.html) (read 2026-09-27)
- Alteryx Designer: [`Join Multiple`](https://help.alteryx.com/current/en/designer/tools/join/join-multiple-tool.html) (read 2026-09-27)
- Bruin: [`Joins`](https://getbruin.com/docs/bruin/core-concepts/semantic-layer.html) (read 2026-09-27)
- Apache DataFusion: [`FULL OUTER JOIN`](https://datafusion.apache.org/user-guide/sql/select.html) (read 2026-09-27)
- Apache DataFusion: [`INNER JOIN`](https://datafusion.apache.org/user-guide/sql/select.html) (read 2026-09-27)
- Apache DataFusion: [`JOIN`](https://datafusion.apache.org/user-guide/sql/select.html) (read 2026-09-27)
- Apache DataFusion: [`Joins (INNER, LEFT, RIGHT, FULL, CROSS)`](https://datafusion.apache.org/user-guide/features.html) (read 2026-09-27)
- Apache DataFusion: [`LEFT OUTER JOIN`](https://datafusion.apache.org/user-guide/sql/select.html) (read 2026-09-27)
- Apache DataFusion: [`NATURAL JOIN`](https://datafusion.apache.org/user-guide/sql/select.html) (read 2026-09-27)
- Apache DataFusion: [`RIGHT OUTER JOIN`](https://datafusion.apache.org/user-guide/sql/select.html) (read 2026-09-27)
- Apache DataFusion: [`join`](https://docs.rs/datafusion/latest/datafusion/dataframe/struct.DataFrame.html) (read 2026-09-27)
- Apache DataFusion: [`join_on`](https://docs.rs/datafusion/latest/datafusion/dataframe/struct.DataFrame.html) (read 2026-09-27)
- DuckDB: [`FROM and JOIN (clause)`](https://duckdb.org/docs/current/sql/query_syntax/from) (read 2026-09-27)
- Duckle: [`Join`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- EasyMorph: [`Merge another table`](https://help.easymorph.com/doku.php?id=transformations:merge) (read 2026-09-27)
- EasyMorph: [`Natural merge`](https://help.easymorph.com/doku.php?id=transformations:naturalmerge) (read 2026-09-27)
- AWS Glue: [`Join`](https://docs.aws.amazon.com/glue/latest/dg/aws-glue-api-crawler-pyspark-transforms-join.html) (read 2026-09-27)
- AWS Glue: [`Join`](https://docs.aws.amazon.com/glue/latest/dg/transforms-configure-join.html) (read 2026-09-27)
- Apache Hop: [`Merge Join`](https://hop.apache.org/manual/latest/pipeline/transforms/mergejoin.html) (read 2026-09-27)
- Apache Hop: [`Multiway Merge Join`](https://hop.apache.org/manual/latest/pipeline/transforms/multimerge.html) (read 2026-09-27)
- Ibis: [`JoinChain`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/relations.py) (read 2026-09-27)
- Ibis: [`JoinLink`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/relations.py) (read 2026-09-27)
- KNIME Analytics Platform: [`DB Joiner`](https://api.hub.knime.com/nodes/*FWHpi7M8fzVHRit0?details=full) (read 2026-09-27)
- KNIME Analytics Platform: [`Joiner`](https://api.hub.knime.com/nodes/*WzkQfvBXnYxub9hJ?details=full) (read 2026-09-27)
- Pentaho Data Integration: [`Merge Join`](https://docs.pentaho.com/pdia-data-integration/9.3-data-integration/pdi-transformation-steps-reference-overview) (read 2026-09-27)
- Pentaho Data Integration: [`Multiway Merge Join`](https://docs.pentaho.com/pdia-data-integration/9.3-data-integration/pdi-transformation-steps-reference-overview) (read 2026-09-27)
- Polars: [`DataFrame.join`](https://docs.pola.rs/api/python/stable/reference/dataframe/modify_select.html) (read 2026-09-27)
- Polars: [`align_frames`](https://docs.pola.rs/api/python/stable/reference/functions.html) (read 2026-09-27)
- Power Query M: [`Table.AddJoinColumn`](https://learn.microsoft.com/en-us/powerquery-m/table-functions#transformation) (read 2026-09-27)
- Power Query M: [`Table.Join`](https://learn.microsoft.com/en-us/powerquery-m/table-functions#transformation) (read 2026-09-27)
- Power Query M: [`Table.NestedJoin`](https://learn.microsoft.com/en-us/powerquery-m/table-functions#transformation) (read 2026-09-27)
- RapidMiner Studio: [`Join`](https://docs.rapidminer.com/latest/studio/operators/blending/table/joins/join.html) (read 2026-09-27)
- RapidMiner Studio: [`Join (In Database)`](https://docs.rapidminer.com/latest/studio/operators/extensions/In-Database%20Processing/indb_blending/indb_join.html) (read 2026-09-27)
- SQLMesh: [`@JOIN`](https://github.com/SQLMesh/sqlmesh/blob/23b237cea7218cc8f338b89c14f0957394a0003b/docs/concepts/macros/sqlmesh_macros.md) (read 2026-09-27)
- Tableau Prep: [`Full`](https://help.tableau.com/current/prep/en-us/prep_combine.htm) (read 2026-09-27)
- Tableau Prep: [`Inner`](https://help.tableau.com/current/prep/en-us/prep_combine.htm) (read 2026-09-27)
- Tableau Prep: [`Join`](https://help.tableau.com/current/prep/en-us/prep_combine.htm) (read 2026-09-27)
- Tableau Prep: [`Join data in the Input step`](https://help.tableau.com/current/prep/en-us/prep_add_input_data.htm) (read 2026-09-27)
- Tableau Prep: [`Left`](https://help.tableau.com/current/prep/en-us/prep_combine.htm) (read 2026-09-27)
- Tableau Prep: [`Right`](https://help.tableau.com/current/prep/en-us/prep_combine.htm) (read 2026-09-27)
- Talend: [`tJoin`](https://help.qlik.com/talend/en-US/components/8.0/processing/processing-component) (read 2026-09-27)
- Trifacta: [`Join datasets`](https://help.alteryx.com/aac/en/trifacta-classic/reference/transformation-reference.html) (read 2026-09-27)
- VisiData: [`join-cols-full`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/features/join.py#L423) (read 2026-09-23)
- VisiData: [`join-cols-inner`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/features/join.py#L423) (read 2026-09-23)
- VisiData: [`join-cols-outer`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/features/join.py#L423) (read 2026-09-23)
- VisiData: [`join-selected`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/features/join.py#L406) (read 2026-09-23)
- VisiData: [`join-selected-full`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/features/join.py#L420) (read 2026-09-23)
- VisiData: [`join-selected-inner`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/features/join.py#L420) (read 2026-09-23)
- VisiData: [`join-selected-outer`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/features/join.py#L420) (read 2026-09-23)
- VisiData: [`join-sheets-all`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/features/join.py#L409) (read 2026-09-23)
- VisiData: [`join-sheets-all-full`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/features/join.py#L422) (read 2026-09-23)
- VisiData: [`join-sheets-all-inner`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/features/join.py#L422) (read 2026-09-23)
- VisiData: [`join-sheets-all-outer`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/features/join.py#L422) (read 2026-09-23)
- VisiData: [`join-sheets-cols`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/features/join.py#L410) (read 2026-09-23)
- VisiData: [`join-sheets-top2`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/features/join.py#L408) (read 2026-09-23)
- VisiData: [`join-sheets-top2-full`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/features/join.py#L421) (read 2026-09-23)
- VisiData: [`join-sheets-top2-inner`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/features/join.py#L421) (read 2026-09-23)
- VisiData: [`join-sheets-top2-outer`](https://github.com/saulpw/visidata/blob/7609212ec2febafa9caba7183cbebfaf49627909/visidata/features/join.py#L421) (read 2026-09-23)
