Du bør undersøge Haversine-formlen. Se venligst nedenfor:
SELECT id, (3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) * sin( radians( lat ) ) ) ) AS distance
FROM markers
HAVING distance < 25
ORDER BY distance;
Dette vil returnere alle poster, der er inden for 25 miles fra input long/lat parret.