[英]SELECT Array elements using Cosmos SQL query
Need to select array elements as row element.需要将 select 数组元素作为行元素。
Cosmos Documents JSON宇宙文档 JSON
1. 1.
{
"CountyId": 1
"CountyCode": "Abbeville",
"Cities": [
{ "CityId": 1, "CityName": "Arborville" }
]
}
2. 2.
{
"CountyId": 2
"CountyCode": "Adair",
"Cities": [
{ "CityId": 2, "CityName": "Ballard" },
{ "CityId": 3, "CityName": "Brashear" },
]
}
And the result that I need would like this.我需要的结果就是这样。
Please try the following query:请尝试以下查询:
SELECT c.CountyId, c.CountyCode, d.CityId, d.CityName FROM c
Join d in c.Cities
This produces the following output:这将产生以下 output:
[
{
"CountyId": 1,
"CountyCode": "Abbeville",
"CityId": 1,
"CityName": "Arborville"
},
{
"CountyId": 2,
"CountyCode": "Adair",
"CityId": 2,
"CityName": "Ballard"
},
{
"CountyId": 2,
"CountyCode": "Adair",
"CityId": 3,
"CityName": "Brashear"
}
]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.