带有非字母数字字段名称的 cosmos db sql 查询 [英] cosmos db sql query with non alphanumeric field name

查看:30
本文介绍了带有非字母数字字段名称的 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?

正常查询 SELECT TOP 10 * FROM collection c ORDER BY c._id.filedname 如果 fieldname$ 开头,如 则不起作用>$oid.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆