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/sql-query-select.md
+45-1Lines changed: 45 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -164,9 +164,53 @@ The results are:
164
164
}
165
165
}]
166
166
```
167
+
## Reserved keywords and special characters
168
+
169
+
If your data contains properties with the same names as reserved keywords such as "order" or "Group" then the queries against these documents will result in syntax errors. You should explicitly include the property in `[]` character to run the query successfully.
170
+
171
+
For example, here's a document with a property named `order` and a property `price($)` that contains special characters:
172
+
173
+
```json
174
+
{
175
+
"id": "AndersenFamily",
176
+
"order": [
177
+
{
178
+
"orderId": "12345",
179
+
"productId": "A17849",
180
+
"price($)": 59.33
181
+
}
182
+
],
183
+
"creationDate": 1431620472,
184
+
"isRegistered": true
185
+
}
186
+
```
187
+
188
+
If you run a queries that includes the `order` property or `price($)` property, you will receive a syntax error.
189
+
190
+
```sql
191
+
SELECT*FROM c wherec.order.orderid ="12345"
192
+
```
193
+
```sql
194
+
SELECT*FROM c wherec.order.price($) >50
195
+
```
196
+
The result is:
197
+
198
+
`
199
+
Syntax error, incorrect syntax near 'order'
200
+
`
201
+
202
+
You should rewrite the same queries as below:
203
+
204
+
```sql
205
+
SELECT*FROM c WHERE c["order"].orderId ="12345"
206
+
```
207
+
208
+
```sql
209
+
SELECT*FROM c WHERE c["order"]["price($)"] >50
210
+
```
167
211
168
212
## Next steps
169
213
170
214
-[Getting started](sql-query-getting-started.md)
171
215
-[Azure Cosmos DB .NET samples](https://github.com/Azure/azure-cosmos-dotnet-v3)
0 commit comments