Skip to content

Commit 1497aa6

Browse files
jason-price-mongodbjason-price-mongodb
andauthored
DOCSP-27736-sql-error (#5889) (#5941)
* DOCSP-27736-sql-error * DOCSP-27736-sql-error * DOCSP-27736-sql-error * DOCSP-27736-sql-error * DOCSP-27736-sql-error * DOCSP-27736-sql-error * DOCSP-27736-sql-error * DOCSP-27736-sql-error * DOCSP-27736-sql-error * DOCSP-27736-sql-error --------- Co-authored-by: jason-price-mongodb <jshfjghsdfgjsdjh@aolsdjfhkjsdhfkjsdf.com>
1 parent 470aae4 commit 1497aa6

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

source/reference/operator/aggregation/lookup.txt

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Definition
2424
the "joined" collection. The :pipeline:`$lookup` stage passes these
2525
reshaped documents to the next stage.
2626

27-
Starting in MongoDB 5.1, :pipeline:`$lookup` works across sharded
27+
Starting in MongoDB 5.1, you can use :pipeline:`$lookup` with sharded
2828
collections.
2929

3030
To combine elements from two different collections, use the
@@ -117,19 +117,25 @@ The :pipeline:`$lookup` takes a document with these fields:
117117
already exists in the input document, the existing field is
118118
*overwritten*.
119119

120-
The operation would correspond to the following pseudo-SQL statement:
120+
The operation corresponds to this pseudo-SQL statement:
121121

122122
.. code-block:: sql
123+
:copyable: false
123124

124-
SELECT *, <output array field>
125-
FROM collection
126-
WHERE <output array field> IN (
127-
SELECT *
125+
SELECT *, (
126+
SELECT ARRAY_AGG(*)
128127
FROM <collection to join>
129128
WHERE <foreignField> = <collection.localField>
130-
);
129+
) AS <output array field>
130+
FROM collection;
131131

132-
See these examples:
132+
.. note::
133+
134+
The SQL statements on this page are included for comparison to the
135+
MongoDB aggregation pipeline syntax. The SQL statements aren't
136+
runnable.
137+
138+
For MongoDB examples, see these pages:
133139

134140
- :ref:`lookup-single-equality-example`
135141
- :ref:`unwind-example`
@@ -246,6 +252,7 @@ The :pipeline:`$lookup` stage accepts a document with these fields:
246252
The operation corresponds to this pseudo-SQL statement:
247253

248254
.. code-block:: sql
255+
:copyable: false
249256

250257
SELECT *, <output array field>
251258
FROM collection
@@ -377,6 +384,7 @@ The :pipeline:`$lookup` accepts a document with these fields:
377384
The operation corresponds to this pseudo-SQL statement:
378385

379386
.. code-block:: sql
387+
:copyable: false
380388

381389
SELECT *, <output array field>
382390
FROM localCollection
@@ -685,6 +693,7 @@ The operation returns these documents:
685693
The operation corresponds to this pseudo-SQL statement:
686694

687695
.. code-block:: sql
696+
:copyable: false
688697

689698
SELECT *, inventory_docs
690699
FROM orders
@@ -946,6 +955,7 @@ The operation returns these documents:
946955
The operation corresponds to this pseudo-SQL statement:
947956

948957
.. code-block:: sql
958+
:copyable: false
949959

950960
SELECT *, stockdata
951961
FROM orders
@@ -1061,6 +1071,7 @@ The operation returns the following:
10611071
The operation corresponds to this pseudo-SQL statement:
10621072

10631073
.. code-block:: sql
1074+
:copyable: false
10641075

10651076
SELECT *, holidays
10661077
FROM absences

0 commit comments

Comments
 (0)