Answer the question
In order to leave comments, you need to log in
How to add a value to jsonb, provided that there is no such value in it?
The task is next. You need to add a value to the jsonb field, like [2,7,835,824,26] another number, provided that it is not there. In other words, add a value to the set in those records that do not have this value in the set.
So far I've come up with this:
UPDATE public.table SET jsonb_field = jsonb_set(jsonb_field, '{1000000000}','4') WHERE jsonb_field NOT IN (SELECT jsonb_field FROM public.table WHERE jsonb_field @> '4');
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question