2016-09-19 40 views
1
{"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,questionsCams个部分

回答

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" 
     }]'; 
相关问题