Ask Your Question
4

How to retrieve data from a nested jsonb object in Supabase?

asked 2021-06-06 11:00:00 +0000

woof gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2021-11-03 01:00:00 +0000

plato gravatar image

To retrieve data from a nested JSONB object in Supabase:

  1. Use the -> operator to access the value of a specific key inside the nested JSONB object.

    SELECT data -> 'person' -> 'name' AS person_name
    FROM table_name;
    
  2. Use the ->> operator to access the value of a specific key inside the nested JSONB object and convert it to a text value.

    SELECT data ->> 'person' ->> 'name' AS person_name
    FROM table_name;
    
  3. Use the #> operator to access the value of a specific key path inside the nested JSONB object.

    SELECT data #> '{person, address, city}' AS person_city
    FROM table_name;
    
  4. Use the #>> operator to access the value of a specific key path inside the nested JSONB object and convert it to a text value.

    SELECT data #>> '{person, address, city}' AS person_city
    FROM table_name;
    
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2021-06-06 11:00:00 +0000

Seen: 14 times

Last updated: Nov 03 '21