【发布时间】:2016-09-15 00:08:00
【问题描述】:
有没有其他方法可以匹配来自 PostgreSQL(9.3 版)json 对象的布尔值而不将其转换为字符串?
我的意思是: 该表在其 jsoncolumn 列中包含以下对象:
'{"path":"mypath", "exists": true}'
以下查询获取记录(请注意,exists 值是作为文本获取的,带有 ->>):
select * from thetable where jsoncolumn ->> 'exists' = 'true';
而这个没有:
select * from thetable where jsoncolumn -> 'exists' = true;
我想知道是否有更合适的方法来进行布尔比较?
【问题讨论】:
-
你试过了吗:
(jsoncolumn -> 'exists')::boolean = true? -
@a_horse_with_no_name 是的,我有。它也没有工作。
标签: json postgresql postgresql-9.3