How to get only the jsonb of specific keys from postgres?

后端 未结 5 534
忘掉有多难
忘掉有多难 2021-02-06 01:10

I\'m aware that you can remove keys from a jsonb in postgres using something like this

select \'{\"a\": 1, \"b\": 2, \"c\":3}\'::jsonb -\'a\';
 ?column?
--------         


        
5条回答
  •  春和景丽
    2021-02-06 01:36

    You can do this

    SELECT jsonb_column->>'key_name_here' as 'column_name_of_your_own' from table_name
    

    In the case of the query asked above, it would be

    select '{"a": 1, "b": 2, "c":3}'::jsonb->>'a'
    

提交回复
热议问题