【发布时间】:2019-05-15 09:28:00
【问题描述】:
这是对56126817的后续问题
我当前的查询
SELECT c.EventType.EndDeviceEventDetail FROM c
WHERE c.EventType.EndDeviceEventType.eventOrAction = '93'
AND c.EventType.EndDeviceEventType.subdomain = '137'
AND c.EventType.EndDeviceEventType.domain = '26'
AND c.EventType.EndDeviceEventType.type = '3'
AND ARRAY_CONTAINS(c.EventType.EndDeviceEventDetail,{"name":
"RCDSwitchReleased","value": "true" })
我的查询输出
[
{
"EndDeviceEventDetail": [
{
"name": "Spontaneous",
"value": "true"
},
{
"name": "DetectionActive",
"value": "true"
},
{
"name": "RCDSwitchReleased",
"value": "true"
}
]
}
]
问题
如何更改我的查询,以便我选择 only 包含“名称”“DetectionActive”的数组的“值”? 背后的想法是过滤一个数组条目的查询,并获得另一个数组条目的“值”作为输出。从这里阅读,应该使用UDF(在这种情况下不是最好的)和JOIN。
第一次尝试
SELECT t.value FROM c JOIN t in c.EventType.EndDeviceEventDetail
WHERE c.EventType.EndDeviceEventType.eventOrAction = '93'
AND c.EventType.EndDeviceEventType.subdomain = '137'
AND c.EventType.EndDeviceEventType.domain = '26'
AND c.EventType.EndDeviceEventType.type = '3'
AND ARRAY_CONTAINS(c.EventType.EndDeviceEventDetail,{"name":
"RCDSwitchReleased","value": "true" })
获取错误请求 (400) 错误
【问题讨论】:
-
您好像发过两次这个问题,第一次是here。很好奇为什么。请不要重复同样的问题。
-
这个问题(Return the content of a specific object in an array — CosmosDB)与您提到的原始问题有点不同,因此认为发布后续问题更合适。不建议在评论字段中发布后续问题(就像我在原始帖子中所做的那样)。
-
看起来完全一样的根本原因:在查询中使用保留字(两个答案都指出)。
标签: azure-cosmosdb azure-cosmosdb-sqlapi