数据结构如下
{
"rows": [
{
"rowId": "IDP_2z8dfj9KbB1hrPI_1554508960_1_1",
"version": "1554508960",
"lastUpdatedDate": 1554508960604,
"createdAt": 1554508960604,
"payload": ""
},
{
"rowId": "IDP_2z8dfj9KbB1hrPI_1554508960_1_2",
"version": "1554508960",
"lastUpdatedDate": 1554508960604,
"createdAt": 1554508960604,
"payload": ""
},
{
"rowId": "IDP_2z8dfj9KbB1hrPI_1554508960_1_3",
"version": "1554508960",
"lastUpdatedDate": 1554508960604,
"createdAt": 1554508960604,
"payload": ""
}
]
}
以下选择查询
select * from S3Object s where 'IDP_2z8dfj9KbB1hrPI_1554508960_1_2' in s[*]."rows"[*]."rowId"
返回整个JSON文档,我希望它仅返回一行,即
[{
"rowId": "IDP_2z8dfj9KbB1hrPI_1554508960_1_2",
"version": "1554508960",
"lastUpdatedDate": 1554508960604,
"createdAt": 1554508960604,
"payload": ""
}]
我尝试了几种查询变体
select s.rows[0] from S3Object s where 'IDP_2z8dfj9KbB1hrPI_1554508960_1_2' in s[*]."rows"[*]."rowId"
仅返回1条记录,但它是错误的记录。
select * from S3Object s where s[*]."rows"[*]."rowId"='IDP_2z8dfj9KbB1hrPI_1554508960_1_2'
不返回任何内容。
关于我在做什么错的任何想法吗?
答案 0 :(得分:1)
对查询进行了多次修改后,我可以通过
获得预期的结果select * from S3Object[*]."rows"[*] as r where ('IDP_2z8dfj9KbB1hrPI_1554508960_1_1') in r[*]."rowId"