Re: Spatial query for the Nearest location given a lat and long?
ok
I'm starting to get somewhere with this thing, but it is still returning incorrect values. I got this working before I read the last two post. I'll try your ideas, and see if they help.
This is what I have so far, but it is returning the wrong values. I'm assuming because the query does not take into account that earth is a sphere.
SELECT id,name
FROM coop.stations
ORDER BY Distance(GeomFromText('POINT(-111.855 47.7833)') ,
GeomFromText('POINT('||coop.stations.longitude||' '||coop.stations.latitude||')')) asc limit 5;
Feel free to point out what I'm doing wrong.
Thanks