I have the following table in postgres with the below schema
Relations
| id | tags |
I need to update the field tags to append unique multiple elements to it I can very well achieve it with like the below
for (String tagId : tagIds ) {
// Execute the below query in PostGRES
UPDATE Relations SET tags = array_append (array_remove (tags, '" + tagId + "'), '" + tagId + "') WHERE id = '" + id + "'";
}
But I want to append an array of elements to it in a single go without the for loop. Can someone let me know the query for that ?
SELECT array_cat(ARRAY['a', 'b'], ARRAY['c', 'd'])--> {a,b,c,d}