I am not familiar with gis or writing sql, so my understanding in this field is lacking. I have a hundreds of lat/lng geographic coordinates stored in a single table called Places like this:
ID | Coordinate
-----------------------------
1 | POINT(192.938 -28.348)
2 | POINT(57.349 -88.482)
They are in 4326, and I'm using geography type. I want to find all nearby points that are within 10 miles of a given point.
I want to use st_dwithin(), but I don't understand how to use it. I came up with this, but it doesn't seem quite right:
SELECT * FROM places WHERE ST_DWithin(places.Coordinate, ST_GeographyFromText('POINT(195.888 -28.348)'), 16093.4);
16093.4 metres is 10 miles.
How do I get all points within 10 miles of a given point (in this example, from POINT(195.888 -28.348))?
ST_DWithin()
takes two geographies, then why does usingplaces.Coordinate
seem okay? Also, I found other threads using a mix of ST_Distance() and ST_DWithin(). I don't understand why ST_Distance was used? Is it applicable for my problem?