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/tutorial-query.md
+17-23Lines changed: 17 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,25 +1,29 @@
1
1
---
2
2
title: 'Tutorial: How to query with SQL in Azure Cosmos DB?'
3
-
description: 'Tutorial: Learn how to query with SQL queries in Azure Cosmos DB using the query playground'
3
+
description: In this tutorial, learn how to query with SQL queries in Azure Cosmos DB using the query playground.
4
4
author: seesharprun
5
5
ms.author: sidandrews
6
6
ms.reviewer: mjbrown
7
7
ms.service: cosmos-db
8
8
ms.subservice: nosql
9
9
ms.custom: tutorial-develop, mvc, ignite-2022
10
10
ms.topic: tutorial
11
-
ms.date: 08/26/2021
11
+
ms.date: 03/07/2023
12
12
---
13
13
14
14
# Tutorial: Query Azure Cosmos DB by using the API for NoSQL
15
15
[!INCLUDE[NoSQL](../includes/appliesto-nosql.md)]
16
16
17
17
The Azure Cosmos DB [API for NoSQL](../introduction.md) supports querying documents using SQL. This article provides a sample document and two sample SQL queries and results.
18
18
19
-
This article covers the following tasks:
19
+
This article covers the following tasks:
20
20
21
21
> [!div class="checklist"]
22
-
> * Querying data with SQL
22
+
> - Query data with SQL
23
+
24
+
## Prerequisites
25
+
26
+
This tutorial assumes you have an Azure Cosmos DB account and collection. Don't have any of those resources? Complete this quickstart: [Create an Azure Cosmos DB account, database, container, and items from the Azure portal](quickstart-portal.md).
23
27
24
28
## Sample document
25
29
@@ -56,28 +60,23 @@ The SQL queries in this article use the following sample document.
56
60
57
61
## Where can I run SQL queries?
58
62
59
-
You can run queries using the Data Explorer in the Azure portal and via the [REST API and SDKs](sdk-dotnet-v2.md).
60
-
61
-
For more information about SQL queries, see:
62
-
*[SQL query and SQL syntax](query/getting-started.md)
63
-
64
-
## Prerequisites
63
+
You can run queries using the Data Explorer in the Azure portal and by using the [REST API and SDKs](sdk-dotnet-v2.md).
65
64
66
-
This tutorial assumes you have an Azure Cosmos DB account and collection. Don't have any of those resources? Complete the [5-minute quickstart](quickstart-portal.md).
65
+
For more information about SQL queries, see [Getting started with queries](query/getting-started.md).
67
66
68
67
## Example query 1
69
68
70
-
Given the sample family document above, following SQL query returns the documents where the ID field matches `WakefieldFamily`. Since it's a `SELECT *` statement, the output of the query is the complete JSON document:
69
+
Given the sample family document, following SQL query returns the documents where the ID field matches `WakefieldFamily`. Since it's a `SELECT *` statement, the output of the query is the complete JSON document:
71
70
72
-
**Query**
71
+
Query:
73
72
74
73
```sql
75
74
SELECT*
76
75
FROM Families f
77
76
WHEREf.id="WakefieldFamily"
78
77
```
79
78
80
-
**Results**
79
+
Results:
81
80
82
81
```json
83
82
{
@@ -112,7 +111,7 @@ Given the sample family document above, following SQL query returns the document
112
111
113
112
The next query returns all the given names of children in the family whose ID matches `WakefieldFamily`.
114
113
115
-
**Query**
114
+
Query:
116
115
117
116
```sql
118
117
SELECTc.givenName
@@ -121,9 +120,9 @@ The next query returns all the given names of children in the family whose ID ma
121
120
WHEREf.id='WakefieldFamily'
122
121
```
123
122
124
-
**Results**
123
+
Results:
125
124
126
-
```
125
+
```json
127
126
[
128
127
{
129
128
"givenName": "Jesse"
@@ -134,19 +133,14 @@ The next query returns all the given names of children in the family whose ID ma
134
133
]
135
134
```
136
135
137
-
138
136
## Next steps
139
137
140
138
In this tutorial, you've done the following tasks:
141
139
142
140
> [!div class="checklist"]
143
-
> * Learned how to query using SQL
141
+
> - Learned how to query using SQL
144
142
145
143
You can now proceed to the next tutorial to learn how to distribute your data globally.
146
144
147
145
> [!div class="nextstepaction"]
148
146
> [Distribute your data globally](tutorial-global-distribution.md)
149
-
150
-
Trying to do capacity planning for a migration to Azure Cosmos DB? You can use information about your existing database cluster for capacity planning.
151
-
* If all you know is the number of vcores and servers in your existing database cluster, read about [estimating request units using vCores or vCPUs](../convert-vcore-to-request-unit.md)
152
-
* If you know typical request rates for your current database workload, read about [estimating request units using Azure Cosmos DB capacity planner](estimate-ru-with-capacity-planner.md)
0 commit comments