具有非字母数字字段名称的cosmos db sql查询 [英] cosmos db sql query with non alphanumeric field name
本文介绍了具有非字母数字字段名称的cosmos db sql查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
接下来是我在cosmosdb中的数据结构
My data structure in cosmosdb is next
{
"_id": {
"$oid": "554f7dc4e4b03c257a33f75c"
},
.................
}
,我需要按$oid
字段对集合进行排序.我应该如何形成我的SQL查询?
and I need to sort collection by $oid
field. How should I form my sql query?
如果fieldname
以$
开头,例如$oid
,则普通查询SELECT TOP 10 * FROM collection c ORDER BY c._id.filedname
不起作用.
Normal query SELECT TOP 10 * FROM collection c ORDER BY c._id.filedname
not works if fieldname
starts with $
like $oid
.
我正在使用azure门户中的查询资源管理器.
I am using query explorer from azure portal.
推荐答案
要使用特殊字符(如$
),您需要使用方括号表示法:
To use a special character, like $
, you need to use bracket notation:
SELECT c._id FROM c
order by c._id["$oid"]
您可以对层次结构中的每个属性执行此操作,因此以下内容也适用:
You can do this with each property in the hierarchy, so the following also works:
SELECT c._id FROM c
order by c["_id"]["$oid"]
这篇关于具有非字母数字字段名称的cosmos db sql查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文