[postgis-users] SQL Loop using ST_Within()H

Paul Ramsey pramsey at opengeo.org
Sat Apr 4 10:34:55 PDT 2009


Welcome to the world of SQL. It's called a "join", the looping is implicit.

SELECT polygonTable.* FROM
  polygonTable JOIN pointTable ON (ST_Within(pointTable.the_geom,
polygonTable.the_geom);

P.

On Sat, Apr 4, 2009 at 9:16 AM, diplonics <paulcaz80 at hotmail.com> wrote:
>
> Hi,
>  I have two geometry tabels, one with four points and the other with 70,000
> polygons. I want to return all the polygons that contain the four points. I
> can easily do this with:
>
> SELECT * FROM polygonTable
> WHERE ST_Within((SELECT the_geom FROM PointTable WHERE gid = 3),
> polygon_geom);
>
> Is there a way to perform this query in a loop so that I don't have to
> change the nested select statement for every point id i need to test.
> Any help appreciated, and thanks in advance.
>
> Diplonics
> --
> View this message in context: http://www.nabble.com/SQL-Loop-using-ST_Within%28%29H-tp22885062p22885062.html
> Sent from the PostGIS - User mailing list archive at Nabble.com.
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>



More information about the postgis-users mailing list