I have a series of lines that I need to join together into a single record. Bellow is a mockup representation of my data. Some section numbers are duplicated and I need to update the geometries of the same section number into a single record.
Mockup Data:
| id | section | geom |
|---|---|---|
| 1 | 32 | 1234 |
| 2 | 32 | 1213 |
| 3 | 32 | 1231 |
| 4 | 33 | 3121 |
What I need:
| id | section | geom |
|---|---|---|
| 1 | 32 | 1234,1213,1231 |
| 4 | 33 | 3121 |
From what I have read ST_union is a good way to to this but can figure out how to update the rows. I think I need to subquery an update query but am unsure how to format this.
Sample Code:
UPDATE TABLE "tlbsections"
SELECT section,
ST_Union(geom) as singlegeom
FROM "Ecorys_alkmaar_sections"
WHERE section = '32'
GROUP BY section
;

