【发布时间】:2020-10-19 05:45:48
【问题描述】:
我有一个表customrule 有一个结构
id. - int
name - varchar
actions. - jsonb
我已经阅读了-> 运算符。但它似乎不适用于我的情况,因为我将数据存储为数组。
+-----------------------------------------------------------------------------------+
| Name | Id | Actions |
+-----------------------------------------------------------------------------------+
| CR-1 | 1 | [{"name": "Action1", "count": "1"},{"name": "Action2", "count": "2"}] |
+-------------------+---------------------------------------------------------------+
| CR-2 | 2 | [{"name": "Action5", "count": "1"},{"name": "Action4", "count": "2"}] |
+-----------------------------------------------------------------------------------+
| CR-3 | 3 | [{"name": "Action1", "count": "1"},{"name": "Action1", "count": "2"}] |
+-----------------------------------------------------------------------------------+
我想查询这些数据并获取在actions 列中使用了Action1 的所有记录。结果应该返回row 1 and 3rd。
【问题讨论】:
标签: sql postgresql jsonb