I'm trying to write a query in SQL Server using 1 set of points and 2 sets of polygons. The polygons overlap, and I only want to select the points that fall inside of 1 polygon but not the other.
I want to duplicate this behavior in ArcGIS for Desktop.
- New Selection by Location Points that Intersect Polygon layer 1
- Remove from the Current Selection by Location Points that Intersect Polygon layer 2
Attempt in SQL Server:
SELECT DISTINCT --MY FIELDS-- FROM Points, Polygons1, Polygons2 WHERE Polygons1.Shape.STIntersects(Points.Shape) = 1 AND Polygons2.Shape.STDisjoint(Points.Shape) = 1
Am I missing something? I think the logic is sound in the SQL query, but it's not working.