@@ -107,17 +107,25 @@ The :pipeline:`$lookup` takes a document with the following fields:
107
107
already exists in the input document, the existing field is
108
108
*overwritten*.
109
109
110
- The operation would correspond to the following pseudo-SQL statement:
110
+ The operation corresponds to this pseudo-SQL statement:
111
111
112
112
.. code-block:: sql
113
+ :copyable: false
113
114
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;
119
121
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:
121
129
122
130
- :ref:`lookup-single-equality-example`
123
131
- :ref:`unwind-example`
@@ -211,6 +219,7 @@ The :pipeline:`$lookup` takes a document with the following fields:
211
219
The operation would correspond to the following pseudo-SQL statement:
212
220
213
221
.. code-block:: sql
222
+ :copyable: false
214
223
215
224
SELECT *, <output array field>
216
225
FROM collection
@@ -433,6 +442,7 @@ The operation returns the following documents:
433
442
The operation would correspond to the following pseudo-SQL statement:
434
443
435
444
.. code-block:: sql
445
+ :copyable: false
436
446
437
447
SELECT *, inventory_docs
438
448
FROM orders
@@ -652,6 +662,7 @@ The operation returns the following documents:
652
662
The operation corresponds to the following pseudo-SQL statement:
653
663
654
664
.. code-block:: sql
665
+ :copyable: false
655
666
656
667
SELECT *, stockdata
657
668
FROM orders
@@ -739,6 +750,7 @@ The operation returns the following:
739
750
The operation would correspond to the following pseudo-SQL statement:
740
751
741
752
.. code-block:: sql
753
+ :copyable: false
742
754
743
755
SELECT *, holidays
744
756
FROM absences
0 commit comments