I have a schema with multiple tables, all of which have a particular field, let's call it
foo. They all have geometry
wkb_geometry and unique key
I need to create two new tables that would have intersections and unions of all features 'foo' equal to 'bar'.
I can do it for two tables specified explicitly:
-- intersection create table intersection_results as select T1.foo, st_intersection(T1.wkb_geometry, T2.wkb_geometry) as geom from T1, T2 where st_intersects(T1.wkb_geometry, T2.wkb_geometry) and T1.foo = 'Bar' ; -- union create table union_results as SELECT st_union(wkb_geometry) FROM ( SELECT wkb_geometry FROM T1 where foo = 'bar' UNION SELECT wkb_geometry FROM T2 where foo = 'bar' ) as moo ;
But what I am struggling with is to create a joined results table across all the tables in my schema.