Skip to content

Commit ca8a7a9

Browse files
jason-price-mongodbjason-price-mongodb
andauthored
DOCSP-27736-sql-error (#5889) (#5947)
* 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 6e71cdc commit ca8a7a9

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

source/reference/operator/aggregation/lookup.txt

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,25 @@ The :pipeline:`$lookup` takes a document with the following fields:
107107
already exists in the input document, the existing field is
108108
*overwritten*.
109109

110-
The operation would correspond to the following pseudo-SQL statement:
110+
The operation corresponds to this pseudo-SQL statement:
111111

112112
.. code-block:: sql
113+
:copyable: false
113114

114-
SELECT *, <output array field>
115-
FROM collection
116-
WHERE <output array field> IN (SELECT *
117-
FROM <collection to join>
118-
WHERE <foreignField>= <collection.localField>);
115+
SELECT *, (
116+
SELECT ARRAY_AGG(*)
117+
FROM <collection to join>
118+
WHERE <foreignField> = <collection.localField>
119+
) AS <output array field>
120+
FROM collection;
119121

120-
See the following examples:
122+
.. note::
123+
124+
The SQL statements on this page are included for comparison to the
125+
MongoDB aggregation pipeline syntax. The SQL statements aren't
126+
runnable.
127+
128+
For MongoDB examples, see these pages:
121129

122130
- :ref:`lookup-single-equality-example`
123131
- :ref:`unwind-example`
@@ -211,6 +219,7 @@ The :pipeline:`$lookup` takes a document with the following fields:
211219
The operation would correspond to the following pseudo-SQL statement:
212220

213221
.. code-block:: sql
222+
:copyable: false
214223

215224
SELECT *, <output array field>
216225
FROM collection
@@ -433,6 +442,7 @@ The operation returns the following documents:
433442
The operation would correspond to the following pseudo-SQL statement:
434443

435444
.. code-block:: sql
445+
:copyable: false
436446

437447
SELECT *, inventory_docs
438448
FROM orders
@@ -652,6 +662,7 @@ The operation returns the following documents:
652662
The operation corresponds to the following pseudo-SQL statement:
653663

654664
.. code-block:: sql
665+
:copyable: false
655666

656667
SELECT *, stockdata
657668
FROM orders
@@ -739,6 +750,7 @@ The operation returns the following:
739750
The operation would correspond to the following pseudo-SQL statement:
740751

741752
.. code-block:: sql
753+
:copyable: false
742754

743755
SELECT *, holidays
744756
FROM absences

0 commit comments

Comments
 (0)