[postgis-users] intersect two tables one row at a time

karsten karsten at terragis.net
Sat Sep 19 14:03:25 PDT 2020


Hi all,
 
I have two polygon geometry tables say A and B and trying to find the ids
from Table B  
where their geometries intersect for each individual record in table A. I
have tried many things that did not work 
and this was my starting point query:
 
Select array_agg(B.id) from A ,B where ST_Intersects(A.geom,B.geom) ;
 
I was expecting to get only the ids of table B that intersect the geometry
of one row, but what this query returns seems
to be a string of all ids the there entire two layers intersect. I don't
understand why that is. 
 
How can I restrict the query above further so that I get back only the ids
for each row (one geometry of table A  at a time with the ids of
intersecting polygons from table B)
 
Cheers
Karsten
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20200919/306dfa61/attachment.html>


More information about the postgis-users mailing list