Home Postgres: jsonb_set Update on join
Reply: 0

Postgres: jsonb_set Update on join

user717
1#
user717 Published in April 22, 2018, 10:10 pm

I have a table that has indexes that I can translate into a jsonb_set path.

This joins to a table that contains my value.

I want to update each of the values in that object to an empty string.

Eg:

Child

parent_id | path
--------------
1         | 0
1         | 1
2         | 0

Parent

id      | node
--------------
1       | ['a','b']
2       | ['c']

Is it possible to update each value of the parent? I can produce this:

select jsonb_set(node, path, '') 
from Parent 
inner join Child on Child.parent_id = Parent.id

but how do I combine those results together?

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.308408 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO