I have two tables - first is a list of positions (points) and second is a list of cities (cities). I am using PostGIS and can find all points outside 10nm of New York by using the SQL statement -
SELECT * FROM points, cities
WHERE ST_Distance(points.position, cities.geom) > 1 AND cities.city = 'New York'
However, if I want to find all points which are outside both New York and Washington, the query with an AND clause gives zero results..
SELECT * FROM points, cities
WHERE (ST_Distance(points.position, cities.geom) > 1 AND cities.city = 'New York')
AND (ST_Distance(points.position, cities.geom) > 1 AND cities.city = 'Washington')
Can you help on constructing an SQL statement which will find all points outside a certain range of multiple cities?
I am also using SQLAlchemy.