I am trying to merge two multipolygon tables into one and at the same time - in the same query - dissolve the boundaries between the polygon districts using postgis.
The two tables are the red polygons and the beige polygons in the map below.
As mentioned, the first thing I want to do is to merge the two tables into one and second I want to dissolve the boundaries based on values in a column name
. Name
are e.g. 'JS22C' and 'JS22A' in the map. I cannot figure out if you do this by doing a join
operation or by using a UNION
/ST_UNION
I have been trying the following:
CREATE OR REPLACE VIEW schema.tablename AS
SELECT row_number() over() as id, st_union(a.the_geom, b.the_geom), name
FROM schema.table1 a, schema.table2 b
GROUP BY name;
But it says that name
is ambiguous which is quite obvious because the column name exists in both tables .
Can anybody help out?