【发布时间】:2020-08-06 08:01:38
【问题描述】:
我有一个 postgres 9.6 表,其中有一个 json 字段 config。我想从此表中获取 json 具有特定键值对的记录。
我的表如下
CREATE TABLE features(
id integer NOT NULL,
plan character,
config json NOT NULL
)
在json字段中,我在表单中存储了一个json
[
{ "name": "A", "state": "active"},
{ "name": "B", "state": "inactive"},
{ "name": "C", "state": "active"}
]
现在,我正在查询数据库以获取 json 字段包含键值对 { "name": "B", "state": "inactive"} 的所有记录。
我的查询如下
select * from features where config @> '[{ "name": "B", "state": "inactive"}]';
但是,我得到一个错误
ERROR: operator does not exist: config @> unknown
知道我在哪里出错了。指针将不胜感激。蒂亚!!!
【问题讨论】: