Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用COSMOSSQL查询选择数组元素_Sql_Azure Cosmosdb - Fatal编程技术网

使用COSMOSSQL查询选择数组元素

使用COSMOSSQL查询选择数组元素,sql,azure-cosmosdb,Sql,Azure Cosmosdb,需要选择数组元素作为行元素 Cosmos文档JSON 一, 二, 我需要的结果是这样的 请尝试以下查询: SELECT c.CountyId, c.CountyCode, d.CityId, d.CityName FROM c Join d in c.Cities 这将产生以下输出: [ { "CountyId": 1, "CountyCode": "Abbeville", "CityId": 1, "CityName":

需要选择数组元素作为行元素

Cosmos文档JSON

一,

二,

我需要的结果是这样的


请尝试以下查询:

SELECT c.CountyId, c.CountyCode, d.CityId, d.CityName FROM c
Join d in c.Cities
这将产生以下输出:

[
    {
        "CountyId": 1,
        "CountyCode": "Abbeville",
        "CityId": 1,
        "CityName": "Arborville"
    },
    {
        "CountyId": 2,
        "CountyCode": "Adair",
        "CityId": 2,
        "CityName": "Ballard"
    },
    {
        "CountyId": 2,
        "CountyCode": "Adair",
        "CityId": 3,
        "CityName": "Brashear"
    }
]

请编辑您的问题,以显示您尝试了什么、遇到了什么问题、预期输出与实际输出等。至于起点:您是否考虑过进行自连接(如Cosmos DB文档中所述)?感谢您的建议,我是Cosmos DB的新手,所以不知道。这就是我一直在寻找的,谢谢!
SELECT c.CountyId, c.CountyCode, d.CityId, d.CityName FROM c
Join d in c.Cities
[
    {
        "CountyId": 1,
        "CountyCode": "Abbeville",
        "CityId": 1,
        "CityName": "Arborville"
    },
    {
        "CountyId": 2,
        "CountyCode": "Adair",
        "CityId": 2,
        "CityName": "Ballard"
    },
    {
        "CountyId": 2,
        "CountyCode": "Adair",
        "CityId": 3,
        "CityName": "Brashear"
    }
]