Searching nested jsonb array in PostgreSQL -
i have orders table store summary of order in jsonb column {"users": [ {"food": [{"name": "dinner", "price": "100"}], "room": "2", "user": "bob"}, {"room": "3", "user": "foo"} ]} now want query users food->name . i tried following, gives me user foo , has no food . select jsonb_array_elements(jsonb_array_elements(summary->'users')->'food')->>'name' food, jsonb_array_elements(summary->'users')->>'user' user_name orders; food | user_name -------+----------- dinner | bob dinner | foo how such query? update i have summery 2 food options {"users": [ {"food": [{"name": "dinner", "price": "100"}, {"name": "breakfast", "price": "100"}], "roo...