Hi everyone!<div><br></div><div>I am having a hard time finding polygons intersecting other polygons recursively. My "projects" relation has an id and a geom. I'd like to start with a project, select all the conflicting (intersecting) projects, then select the projects that conflict with that, etc. </div>

<div>As near as I can figure, I need a recursive query, so after many attempts I have this:</div><div><br></div><div><div>WITH RECURSIVE tp(project_id, conflict_id, conflict_geom) AS</div><div>(</div><div> SELECT <a href="http://projects.id">projects.id</a>, <a href="http://conflicts.id">conflicts.id</a>, conflicts.the_geom </div>

<div> FROM projects, projects as conflicts </div><div> WHERE <a href="http://projects.id">projects.id</a> = 1740 and (ST_Intersects(projects.the_geom, conflicts.the_geom))</div><div> UNION</div><div> SELECT <a href="http://conflicts.id">conflicts.id</a>, tp.conflict_id, tp.conflict_geom</div>

<div> FROM tp, projects as conflicts where (ST_Intersects(tp.conflict_geom, conflicts.the_geom))</div><div>)</div><div>SELECT * from tp;</div></div><div><br></div><div><br></div><div>This gives me:</div><div><div>ERROR:  could not implement recursive UNION</div>

<div>DETAIL:  All column datatypes must be hashable.</div></div><div><br></div><div><br></div><div>I assume that's because of the geometry - can UNION not work with a geom?</div><div><br></div><div><br></div><div>My ultimate goal is for my program to get a list of all the conflicts and conflicts of conflicts (and conflicts of conflicts of conflicts...) for every project, like so:</div>

<div><br></div><div>id   conflicts</div><div>1    7, 6, 3, 4</div><div>3    1, 19, 32</div><div><br></div><div><br></div><div>I already do this programmatically , but its too slow.</div><div><br></div><div><br></div><div>

I'd appreciate any tips!</div><div><br></div><div>Leslie</div><div><br></div>