i want to search near by location with given latitude and longitude in mysql latitude is : 26.902 longitude is : 75.793 and distance is : 30
Query is :
SELECT
id, (
3959 * acos (
cos ( radians(26.902) )
* cos( radians( latitude ) )
* cos( radians( longitude ) - radians(75.793) )
+ sin ( radians(26.902) )
* sin( radians( latitude ) )
)
) AS distance
FROM business
HAVING distance < 30
ORDER BY distance
LIMIT 0 , 20;
Result: i am getting a record with distance is 3.58, record lat/long are 26.89 / 75.74
but when i check online on other site i got distance 5.759 miles .
Spherical Law of Cosines
to find distance between 2 points on earth surface(straight-line). Your result seems to be in the right ball park. The larger distance is probably that of route distance between 2 points. There is no easy way to calculate this from lat/lng points. – david strachan