How to use ST_DWithin to find near point?
gis, postgis, sql
Solution
SELECT *
FROM atm_finder
WHERE ST_Distance(ST_Transform(ST_GeomFromText('POINT([Lon] [Lat])',4326),26986),ST_Transform(location,26986)) <= 1000
Where [Lon] & [Lat] - GPS coordinates of the point. But so far as you used POINT type at first use:
SELECT AddGeometryColumn('atm_finder', 'location', 4326, 'POINT', 2);
Of course before that you should rename the field 'location' (in order to not lose the data) and fill the new one with this data.
Problem
This is the first time I create a GIS query. In one table of my database, there is a column with point type. Each record is one ATM machine. I want to write a query to get ATM machines that near by my location within 1km range.How to use ST_DWithin in SQL query to find record?