As the title suggests, I'm having a hard time, guessing how I can efficiently update a value in multiple rows. The column is implemented with the data-type ltree
. So, there should be some form of special operations available for this data type in postgresql
Here's an example:
Name of the table, let's say: product_sections
and the name of the column containing these values is section_path (type: ltree)
Android
Android.Browser
Android.Browser.Test
Android.Browser.Compare.URL
Here, I want to update only the Browser
to something like Foo
part so that, the data will become like this:
Android
Android.Foo
Android.Foo.Test
Android.Foo.Compare.URL
Thanks in advance :)
update product_sections
set product_path = 'Android.foo'::lpath|| subpath(product_sections,2))
where product_path <@ 'Android.browser'::lpath
untested, but this should achieve the correct result.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With