postgresql 9.5 using jsonb_set for updating specific jsonb array value
Currently I am working with postgreSQL 9.5 and try to update a value inside an array of a jsonb field. But I am unable to get the index of the selected value My table just looks like: CREATE TABLE samples ( id serial, sample jsonb ); My JSON looks like: {"result": [ {"8410": "ABNDAT", "8411": "Abnahmedatum"}, {"8410": "ABNZIT", "8411": "Abnahmezeit"}, {"8410": "FERR_R", "8411": "Ferritin"} ]} My SELECT statement to get the correct value works: SELECT id, value FROM samples s, jsonb_array_elements(s.sample#>'{result}') r WHERE s.id = 26 and r->>'8410' = 'FERR_R'; results in: id | value --------