I have a polygon and I want to get all the points inside from a georeference table.
What is the SQL for that?
For example, obtain all the lat/long records that are inside the department ZZ polygon.
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It only takes a minute to sign up.Sign up to join this community
Much easier if you post your table structure and what you've tried so far, but here goes.
Assuming you have a table points with a column point of type geometry, and a table polygons with a column polygon of type geometry:
SELECT p.* FROM points p INNER JOIN polygons y ON ST_CONTAINS(y.geometry, p.geometry) WHERE y.department = 'ZZ'
If your points don't have geometry, but lon / lat columns, you can do
ST_POINT(lon,lat) to convert them to geometry.