我有一个jsonb列,它的结构如下:
{
.....other fields,
"a" : {
"b" : {
"c" : "some value",
....other fields
}
.....other fields
},
...other fields
}
我可以有这样的查询,属性是表MyTable:中的列名
SELECT * from
MyTable t
WHERE t.properties @> '{"a":{"b":{"c": "some value"}}}';
但有可能的是;c";不同的(我们可以有(
{
.....other fields,
"m" : {
"n" : {
"c" : "some value",
....other fields
}
.....other fields
},
...other fields
}
如何针对这种情况修改我的查询?
如果嵌套始终处于同一级别,则可以使用JSON/Path表达式:
select *
from the_table
where properties @@ '$.*.*.c == "some value"'