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

后端 未结 5 484
忘掉有多难
忘掉有多难 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:45

    I actually found that this way works to.

    select jsonb_build_object('key', column->'key') from table;
    

    reference: https://www.reddit.com/r/PostgreSQL/comments/73auce/new_user_to_postgres_can_i_grab_multiple_keys_of/

提交回复
热议问题