【发布时间】:2018-10-18 16:50:34
【问题描述】:
我正在尝试学习如何过滤 jsonb 数据。当我跑步时:
SELECT DISTINCT jsonb_array_elements(data)
FROM reports
WHERE data @> '[{"status": "Active"}]'
而不是只返回 status: Active 的行,它似乎忽略了 WHERE 子句,我还返回包含 status: Inactive 的行
寻求帮助以了解这里发生了什么。
数据看起来像
[{"report": "Report1", "status": "Active"},
{"report": "Report2", "status": "Inactive"},
{"report": "Report3", "status": "Inactive"},
{"report": "Report4", "status": "Active"}]
【问题讨论】:
标签: sql postgresql jsonb