[postgis-users] Join Help

Paul Ramsey pramsey at refractions.net
Sun Feb 4 09:19:36 PST 2007


I think you want to take everything in A and remove all the things  
that have interactions with B. So, loosely:

select * from A where A.id not in (select A.id where A.geom && B.geom);

There is probably a more efficient formulation using the SQL EXCEPT  
clause.

P

On 4-Feb-07, at 9:13 AM, Stephen Woodbridge wrote:

> Hi,
>
> How do a construct a query to count the number of polygons in table  
> a the have no interaction with any polygon in table b?
>
> select count(*) from a, b where not a.the_geom && b.the_geom
>
> is not it. This seems to count all the polygons in b that do not  
> interact with the polygons in a.
>
> So if a has one polygon and b has 100, then the count(*) would be  
> 100 if the polygon in a did not interact with any of the polygons  
> in b. Or that is at least what I surmise based on the numbers I'm  
> seeing.
>
> Ideas?
>
> -Steve
>
> _______________________________________________
> 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