From c0c8a7235493cb2889eb9a31966ebddecea4616a Mon Sep 17 00:00:00 2001 From: "mintlify[bot]" <109931778+mintlify[bot]@users.noreply.github.com> Date: Fri, 17 Apr 2026 22:14:46 +0000 Subject: [PATCH 1/2] Document multi-column join conditions in Sync Streams Generated-By: mintlify-agent --- sync/streams/queries.mdx | 27 +++++++++++++++++++++++++++ sync/supported-sql.mdx | 3 +++ 2 files changed, 30 insertions(+) diff --git a/sync/streams/queries.mdx b/sync/streams/queries.mdx index 8e4838f4..3124186b 100644 --- a/sync/streams/queries.mdx +++ b/sync/streams/queries.mdx @@ -212,6 +212,33 @@ streams: WHERE gm2.user_id = auth.user_id() ``` +### Multi-column join conditions + +You can join two tables on multiple columns in the same `WHERE` clause. This is useful when a relationship is defined by a composite key — for example, matching on both a region and an ID: + +```yaml +streams: + region_items: + query: | + SELECT a.* FROM a, b + WHERE a.region = b.region + AND a.item_id = b.item_id + AND b.user_id = auth.user_id() +``` + +This also works when chaining joins across several tables: + +```yaml +streams: + linked_records: + query: | + SELECT a.* FROM a + JOIN b ON a.col1 = b.col1 + JOIN c ON b.col2 = c.col2 + JOIN d ON c.col3 = d.col3 + WHERE d.col4 = a.col4 +``` + ### Join Limitations When writing stream queries with JOINs, keep in mind: use only `JOIN` or `INNER JOIN`; select columns from a single table (e.g. `comments.*`); and use simple equality conditions (`table1.column = table2.column`). For the full list of supported JOIN syntax and invalid examples, see [Supported SQL — JOIN syntax](/sync/supported-sql#join-syntax). diff --git a/sync/supported-sql.mdx b/sync/supported-sql.mdx index 9b5d91f8..4d355fbb 100644 --- a/sync/supported-sql.mdx +++ b/sync/supported-sql.mdx @@ -270,6 +270,9 @@ Sync Streams support a subset of join syntax. The following rules define what is -- Valid: columns from one table SELECT comments.* FROM comments INNER JOIN issues ON comments.issue_id = issues.id +-- Valid: multiple equality conditions between tables (composite keys) +SELECT a.* FROM a, b WHERE a.region = b.region AND a.item_id = b.item_id AND b.user_id = auth.user_id() + -- Invalid: columns from multiple tables SELECT comments.*, issues.title FROM comments JOIN issues ON comments.issue_id = issues.id From 7eb8baeb049a1c27ec0d2a7d93ff8959b0dd6493 Mon Sep 17 00:00:00 2001 From: Benita Volkmann Date: Wed, 22 Apr 2026 16:43:23 +0200 Subject: [PATCH 2/2] Improve composite key example --- sync/streams/queries.mdx | 27 --------------------------- sync/supported-sql.mdx | 7 +++++-- 2 files changed, 5 insertions(+), 29 deletions(-) diff --git a/sync/streams/queries.mdx b/sync/streams/queries.mdx index 3124186b..8e4838f4 100644 --- a/sync/streams/queries.mdx +++ b/sync/streams/queries.mdx @@ -212,33 +212,6 @@ streams: WHERE gm2.user_id = auth.user_id() ``` -### Multi-column join conditions - -You can join two tables on multiple columns in the same `WHERE` clause. This is useful when a relationship is defined by a composite key — for example, matching on both a region and an ID: - -```yaml -streams: - region_items: - query: | - SELECT a.* FROM a, b - WHERE a.region = b.region - AND a.item_id = b.item_id - AND b.user_id = auth.user_id() -``` - -This also works when chaining joins across several tables: - -```yaml -streams: - linked_records: - query: | - SELECT a.* FROM a - JOIN b ON a.col1 = b.col1 - JOIN c ON b.col2 = c.col2 - JOIN d ON c.col3 = d.col3 - WHERE d.col4 = a.col4 -``` - ### Join Limitations When writing stream queries with JOINs, keep in mind: use only `JOIN` or `INNER JOIN`; select columns from a single table (e.g. `comments.*`); and use simple equality conditions (`table1.column = table2.column`). For the full list of supported JOIN syntax and invalid examples, see [Supported SQL — JOIN syntax](/sync/supported-sql#join-syntax). diff --git a/sync/supported-sql.mdx b/sync/supported-sql.mdx index 4d355fbb..74de319e 100644 --- a/sync/supported-sql.mdx +++ b/sync/supported-sql.mdx @@ -270,8 +270,11 @@ Sync Streams support a subset of join syntax. The following rules define what is -- Valid: columns from one table SELECT comments.* FROM comments INNER JOIN issues ON comments.issue_id = issues.id --- Valid: multiple equality conditions between tables (composite keys) -SELECT a.* FROM a, b WHERE a.region = b.region AND a.item_id = b.item_id AND b.user_id = auth.user_id() +-- Valid: multiple equality conditions (composite keys) +SELECT comments.* FROM comments, issues + WHERE comments.issue_id = issues.id + AND comments.region = issues.region + AND issues.user_id = auth.user_id() -- Invalid: columns from multiple tables SELECT comments.*, issues.title FROM comments JOIN issues ON comments.issue_id = issues.id