I want to select every row that has args.args_json.actions ==> any id to 79
{
"args": {
"args_json": {
"actions": [
{
"id": 79
},
{
"id": 47
},
{
"id": 82
}
]
}
}
}
I tried args #> '{args_json,actions,0}' ->> 'id' = '79'
and it works but only to check index 0.
I would like the same but returns true if any of id is 79, not only the index 0.
CodePudding user response:
args #> '{args_json,actions}' @> '[{"id":79}]' ;
CodePudding user response:
There is no need to dereference, you can simply use the containment operator @>
with a bigger JSON:
WHERE args @> '{ "args_json": { "actions": [ { "id":79 } ] } }'