<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=us-ascii" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 11.00.9600.19597"></HEAD>
<BODY>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN class=692444920-19092020>Hi 
all,</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN 
class=692444920-19092020></SPAN></FONT> </DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN class=692444920-19092020>I have 
two polygon geometry tables say A and B and trying to find the ids 
from Table B  </SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN class=692444920-19092020>where 
their geometries intersect for each individual record in table A. I have tried 
many things that did not work </SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN class=692444920-19092020>and 
this was my starting point query:</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN 
class=692444920-19092020></SPAN></FONT> </DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN class=692444920-19092020>Select 
array_agg(B.id) from A ,B </SPAN></FONT><FONT color=#000080 size=2 
face=Arial><SPAN class=692444920-19092020>where ST_Intersects(A.geom,B.geom) 
;</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN 
class=692444920-19092020></SPAN></FONT> </DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN class=692444920-19092020>I was 
expecting to get only the ids of table B that intersect the geometry of one row, 
but what this query returns seems</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN class=692444920-19092020>to be 
a string of all ids the there entire two layers intersect. I don't 
understand why that is. </SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN 
class=692444920-19092020></SPAN></FONT> </DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN class=692444920-19092020>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)</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN 
class=692444920-19092020></SPAN></FONT> </DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN 
class=692444920-19092020>Cheers</SPAN></FONT></DIV>
<DIV><FONT color=#000080 size=2 face=Arial><SPAN 
class=692444920-19092020>Karsten</SPAN></FONT></DIV></BODY></HTML>