You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cosmos-db/nosql/query/join.md
-106Lines changed: 0 additions & 106 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -316,112 +316,6 @@ WHERE
316
316
]
317
317
```
318
318
319
-
## Under the hood - syntax
320
-
321
-
The query language supports the syntax `<from_source1> JOIN <from_source2> JOIN ... JOIN <from_sourceN>`. This query returns a set of tuples with `N` values. Each tuple has values produced by iterating all container aliases over their respective sets.
Let each source define `input_alias1, input_alias2, …, input_aliasN`. This `FROM` clause returns a set of `N`-tuples (tuple with `N` values). Each tuple has values produced by iterating all container aliases over their respective sets.
330
-
331
-
### First example (two sources)
332
-
333
-
- Let `<from_source1>` be container-scoped and represent set **{A, B, C}**.
334
-
335
-
- Let `<from_source2>` be item-scoped referencing `input_alias1` and represent sets:
336
-
337
-
-**{1, 2}** for `input_alias1 = A`
338
-
339
-
-**{3}** for `input_alias1 = B`
340
-
341
-
-**{4, 5}** for `input_alias1 = C`
342
-
343
-
- The FROM clause `<from_source1> JOIN <from_source2>` will result in the following tuples:
344
-
345
-
- (`input_alias1, input_alias2`):
346
-
347
-
-`(A, 1)`
348
-
349
-
-`(A, 2)`
350
-
351
-
-`(B, 3)`
352
-
353
-
-`(C, 4)`
354
-
355
-
-`(C, 5)`
356
-
357
-
### Second example (three sources)
358
-
359
-
- Let `<from_source1>` be container-scoped and represent set **{A, B, C}**.
360
-
361
-
- Let `<from_source2>` be item-scoped referencing `input_alias1` and represent sets:
362
-
363
-
-**{1, 2}** for `input_alias1 = A`
364
-
365
-
-**{3}** for `input_alias1 = B`
366
-
367
-
-**{4, 5}** for `input_alias1 = C`
368
-
369
-
- Let `<from_source3>` be item-scoped referencing `input_alias2` and represent sets:
370
-
371
-
-**{100, 200}** for `input_alias2 = 1`
372
-
373
-
-**{300}** for `input_alias2 = 3`
374
-
375
-
- The FROM clause `<from_source1> JOIN <from_source2> JOIN <from_source3>` will result in the following tuples:
376
-
377
-
-`(input_alias1, input_alias2, input_alias3)`:
378
-
379
-
-`(A, 1, 100)`
380
-
381
-
-`(A, 1, 200)`
382
-
383
-
-`(B, 3, 300)`
384
-
385
-
> [!NOTE]
386
-
> This example results includes a lack of tuples for other values of `input_alias1` and `input_alias2`. For these input values, `<from_source3>` did not return any values.
387
-
388
-
### Third example (three sources)
389
-
390
-
- Let `<from_source1>` be container-scoped and represent set **{A, B, C}**.
391
-
392
-
- Let `<from_source2>` be item-scoped referencing `input_alias1` and represent sets:
393
-
394
-
-**{1, 2}** for `input_alias1 = A`
395
-
396
-
-**{3}** for `input_alias1 = B`
397
-
398
-
-**{4, 5}** for `input_alias1 = C`
399
-
400
-
- Let `<from_source3>` be scoped to `input_alias1` and represent sets:
401
-
402
-
-**{100, 200}** for `input_alias2 = A`
403
-
404
-
-**{300}** for `input_alias2 = C`
405
-
406
-
- The FROM clause `<from_source1> JOIN <from_source2> JOIN <from_source3>` will result in the following tuples:
407
-
408
-
-`(input_alias1, input_alias2, input_alias3)`:
409
-
410
-
-`(A, 1, 100)`
411
-
412
-
-`(A, 1, 200)`
413
-
414
-
-`(A, 2, 100)`
415
-
416
-
-`(A, 2, 200)`
417
-
418
-
-`(C, 4, 300)`
419
-
420
-
-`(C, 5, 300)`
421
-
422
-
> [!NOTE]
423
-
> This query resulted in a cross product between `<from_source2>` and `<from_source3>` because both are scoped to the same `<from_source1>`.This result includes four (**2x2**) tuples having value `A`, no tuples having value `B` (**1x0**) and two (**2x1**) tuples having value `C`.
424
-
425
319
## Next steps
426
320
427
321
-[Getting started with queries](getting-started.md)
0 commit comments