更新
object_as_json
现在是jsonb
数据类型
人员表中的一项,有
object_as_json ='{"first":"Joe","last":"Doe","middle":"S","DOB":"1940-01-01"}'
我的查询是(这些都不返回任何内容):
select *
from bw.people
where object_in_json = '{"last":"Doe","first":"Joe"}'
select *
from bw.people
where object_in_json = '{"first":"Joe","last":"Doe","middle":"S","DOB":"1940-01-01"}'
如果您使用jsonb
,则可以编写
WHERE object_in_json @> '{"last":"Doe","first":"Joe"}`
使用json
您必须编写
WHERE object_in_json ->> 'last' = 'Doe'
AND object_in_json ->> 'first' = 'John'