{"create_channel":"1","update_comm":"1","channels":"*"}
这是我要查询的数据库字段。
如果我想选择所有包含"create_channel": "1"
和"update_comm": "1"
其他问题:
查看以下字段:
{"create_channel":"0","update_comm":"0","channels":[{"ch_id":"33","news":"1","parties":"1","questions ":"1","cam":"1","edit":"1","view_subs":"1","invite_subs":"1"},{"ch_id":"18","news":"1","parties":"1","questions ":"1","cam":"1","edit":"1","view_subs":"1","invite_subs":"1"}]}
我如何查找News
,parties
,questions
和Cams
部分中的所有子请点
答案 0 :(得分:1)
您可以使用the ->>
operator将成员作为字符串返回:
select *
from YourTable
where YourColumn->>'create_channel' = '1' and
YourColumn->>'update_comm' = '1'
要查找在第33频道中有新闻,参与方,问题和广告的用户,您可以使用the @>
operator检查频道数组是否包含这些属性:
select *
from YourTable
where YourColumn->'channels' @> '[{
"ch_id":"33",
"news":"1",
"parties":"1",
"questions ":"1",
"cam":"1"
}]';