我无法从这个JSON数组中得到一个特定的行。因此,我想得到一个对象,其中的“type”等于“No-Data”
SQL中是否存在任何函数来接受行或某些表达式?
"metadata": { "value": "JABC" },
"force": false
"users": [
{ "id": "111", "comment": "aaa", type: "Data" },
{ "id": "222", "comment": "bbb" , type:"No-Data"},
{ "id": "333", "comment": "ccc", type:"Data" }
]发布于 2022-08-11 05:27:17
您可以使用JSON路径查询:
select jsonb_path_query_first(the_column, '$.users[*] ? (@.type == "No-Data")')
from the_table这假设列被定义为jsonb (它应该是)。如果它不是你必须要投的:the_column::jsonb
https://stackoverflow.com/questions/73315579
复制相似问题