I have table products
, in which there is an hstore array field countries_of_origin
.
So a product that is assembled from multiple products might have multiple countries of origin:
[
{ "country" => "USA" },
{ "country" => "MEX" }
]
My only issue is, I have no idea whatsoever on how to write a SQL update
. Our developers interact with the table via an ORM. But I sometimes have to do a mass update for expediency's sake, and I don't know to do it!
Thanks for any help you can offer.
Best Answer
Look at the examples for
hstore
in the PostgreSQL documentation.UPDATE tab SET h = h || ARRAY['b => 2'::hstore,'c => 3'::hstore];