# Cross join tables

Join / cross

cross join, cartesian product

Page: <https://meridian.online/operations/cross-join-tables>

## Status

Runs as a SQL step.

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

## The DuckDB step

every combination

It reads the `orders` table the proofs share. Create it 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);
```

Then run the statement:

```sql
CREATE TEMP TABLE result AS
SELECT r.region, p.product FROM (SELECT DISTINCT region FROM orders WHERE region IS NOT NULL) r CROSS JOIN (SELECT DISTINCT product FROM orders) p;
SELECT * FROM result ORDER BY ALL;
SELECT CASE WHEN ((SELECT count(*) = 12 AND count(DISTINCT (region, product)) = 12 FROM result)) THEN 'as expected' ELSE error('four regions and three products did not give twelve pairs') END AS verdict;
```

It needs nothing installed beyond DuckDB itself.

## Variants

- Pair every row with every row: Return every combination of a row from one table with a row from another, optionally limited by a condition.
- Append columns by position: Put the columns of several tables side by side, row by row.
- Add a single value to every row: Take one value from another table and add it as a column on every row.

## What other tools call it

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

- Alteryx Designer: [`Append Fields`](https://help.alteryx.com/current/en/designer/tools/join/append-fields-tool.html) (read 2026-09-27)
- Apache DataFusion: [`CROSS JOIN`](https://datafusion.apache.org/user-guide/sql/select.html) (read 2026-09-27)
- Duckle: [`Cross Join`](https://github.com/slothflowlabs/duckle/blob/f85f8960edfb6efbf4cb89d58a7b32e16df0e867/website/docs/components.html) (read 2026-09-25)
- EasyMorph: [`Cross merge`](https://help.easymorph.com/doku.php?id=transformations:crossmerge) (read 2026-09-27)
- EasyMorph: [`Peek`](https://help.easymorph.com/doku.php?id=transformations:peek) (read 2026-09-27)
- Apache Hop: [`Join Rows`](https://hop.apache.org/manual/latest/pipeline/transforms/joinrows.html) (read 2026-09-27)
- Ibis: [`ScalarSubquery`](https://github.com/ibis-project/ibis/blob/05d2b293344e86cb41c1a426071734f7e270335a/ibis/expr/operations/subqueries.py) (read 2026-09-27)
- KNIME Analytics Platform: [`Column Appender`](https://api.hub.knime.com/nodes/*XRiXb2lpmqhgteMU?details=full) (read 2026-09-27)
- KNIME Analytics Platform: [`Cross Joiner`](https://api.hub.knime.com/nodes/*HG3L-oE4gau2HJVb?details=full) (read 2026-09-27)
- Pentaho Data Integration: [`Join Rows (cartesian product)`](https://docs.pentaho.com/pdia-data-integration/9.3-data-integration/pdi-transformation-steps-reference-overview) (read 2026-09-27)
- RapidMiner Studio: [`Cartesian Product`](https://docs.rapidminer.com/latest/studio/operators/blending/table/joins/cartesian_product.html) (read 2026-09-27)
