Reputation: 2928
I have a jsonb column that stores values like this:
{"v":"0","c":"ACC",...}
I'd like to update some of the v
values to 1
Is there any built-in function to do that in postgresql?
E: I'm using v9.6
Upvotes: 0
Views: 61
Reputation: 310
With Postgresql 9.5
UPDATE test SET data = data - 'v' || '{"v":1}' WHERE data->>'c' = 'ACC';
OR
UPDATE test SET data = jsonb_set(data, '{v}', '1'::jsonb);
Upvotes: 1