postgresql jsonb parsing attributes

postgresql jsonb parses attributes, queries and sorts them;

1. Example of other_name field

[{
    
    "title": "BQ Product", "value": "aValue"}, {
    
    "title": "CTB Product", "value": "bValue"}]

2. Inquiry

select (other_name->0) from dim_product_mapping 
select (other_name->0)::jsonb->'title' from dim_product_mapping 
select (other_name->0)::jsonb->'value' from dim_product_mapping 

3. Sorting

select * from dim_product_mapping where 1=1  order by (other_name->0)::jsonb->'value',update_time desc limit 12 offset 0

Note: it is jsonb, not json

Guess you like

Origin blog.csdn.net/leinminna/article/details/113860831