检查一下,
SELECT id, ( 6371 * acos( cos( radians(37) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(50.2122211145) ) + sin( radians(30.02111454) ) * sin( radians( latitude ) ) ) )
AS distance
FROM markers
HAVING distance < 20 ORDER BY distance LIMIT 0 , 20;
请参阅此wiki page和此document