@@ -8,7 +8,7 @@ In SQL, the `SELECT` statement allows us to specify which columns to retrieve fr
8
8
db .collection .find ({ < query> }, { projection })
9
9
```
10
10
11
- ## ** Projection Basics **
11
+ ## ** Projection basics **
12
12
13
13
- By default, MongoDB returns all fields in a document.
14
14
- Use projection to ** include (1)** or ** exclude (0)** specific fields.
@@ -21,7 +21,7 @@ db.collection.find({ <query> }, { projection })
21
21
db .books .find ({}, { title: 1 , authors: 1 , _id: 0 });
22
22
```
23
23
24
- ** Equivalent SQL Query :**
24
+ ** Equivalent SQL query :**
25
25
26
26
``` sql
27
27
SELECT title, authors FROM books;
40
40
db .books .find ({}, { reviews: 0 });
41
41
```
42
42
43
- ** Equivalent SQL Query :**
43
+ ** Equivalent SQL query :**
44
44
45
45
``` sql
46
46
SELECT title, authors, genres, totalInventory, available FROM books;
@@ -52,13 +52,13 @@ Here:
52
52
53
53
---
54
54
55
- ## ** Example 3: Using Projection along with a Query **
55
+ ## ** Example 3: Using projection along with a query **
56
56
57
57
``` js
58
58
db .books .find ({ genres: " Science" }, { title: 1 , totalInventory: 1 , _id: 0 });
59
59
```
60
60
61
- ** Equivalent SQL Query :**
61
+ ** Equivalent SQL query :**
62
62
63
63
``` sql
64
64
SELECT title, totalInventory FROM books WHERE genres= ' Science' ;
0 commit comments