Re: jsonb : find row by array object attribute

2018-12-30 Thread Andrew Gierth
> "Andrew" == Andrew Gierth writes: > "Rory" == Rory Campbell-Lange writes: Rory> and data like this: Rory> j Rory> -- Rory> {"a": 1, "people": [{"id": 2002}, {"id": 2004}]} Rory> {"a": 3, "people": [{"id": 200

Re: jsonb : find row by array object attribute

2018-12-30 Thread Andrew Gierth
> "Rory" == Rory Campbell-Lange writes: Rory> and data like this: Rory> j Rory> -- Rory> {"a": 1, "people": [{"id": 2002}, {"id": 2004}]} Rory> {"a": 3, "people": [{"id": 20

Re: jsonb : find row by array object attribute

2018-12-30 Thread Tom Lane
Rory Campbell-Lange writes: > ... I can't work out how to return the whole row containing a desired > people id value. Something like this, maybe? =# select * from x where '2003'::jsonb in (select jsonb_array_elements(j #>'{people}')->'id'); j -