TransWikia.com

Updating and merging geometries using a 3rd table as the connector

Geographic Information Systems Asked by Sven Walbers on April 19, 2021

I’m looking for some help with the following.

I have 3 tables in my Oracle Database.

Table A:

IDnumber  Geometry    
001       Geom1
002       Geom2
003       Geom3

Table B:

IDnumber  Fieldnumber (neither of these are unique fields)
001       Field1
001       Field2
002       Field3
003       Field1
003       Field4

Table C:

Fieldnumber  Geometry 
Field1       Geometry1
Field2       Geometry2
Field3       Geometry3
Field4       Geometry4

I want to update the geometries from Table A with the geometries from Table C using Table B as the connector. If there is more than 1 Fieldnumber for each IDnumber in Table B, I want the geometries from Table C to merge.

My update SQL so far:

Update TableA a 
Set 
a.Geometry = (select c.Geometry from TableC c where c.Fieldnumber = b.Fieldnumber) 
Where
a.IDnumber in (select b.IDnumber from TableB b)

This only works when the TableB IDnumbers are unique. How can I merge them? With StUnion? If so how does that work? I don’t understand the code.

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP