小编Pra*_*oni的帖子

如何通过键值从postgres jsonb中删除元素?

我有一个这种格式的 jsonb 列。

{
    "categoryList": [{
        "category_menu_id": "51",
        "is_featured_product": 0
    }, {
        "category_menu_id": "54",
        "is_featured_product": 1
    }]
}
Run Code Online (Sandbox Code Playgroud)

如何通过 category_menu_id 删除类别?

这个选择查询通过 category_menu_id 工作正常。

select product_category 
from product  
where product_category->'categoryList' @> '[{"category_menu_id": "51"}]';
Run Code Online (Sandbox Code Playgroud)

postgresql jsonb postgresql-9.6

5
推荐指数
1
解决办法
2988
查看次数

标签 统计

jsonb ×1

postgresql ×1

postgresql-9.6 ×1