I am trying to create a query to get the distance between 2 locations.
https://developers.google.com/maps/solutions/store-locator/clothing-store-locator
Sample from the link:
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 LIMIT 0 , 20;
Based on the sample link I have created the following query.
select ( 6371 * acos( cos( radians(3.139003) ) * cos( radians( 3.10726 ) ) * cos( radians( 101.60671 ) - radians(101.68685499999992) ) + sin( radians(3.139003) ) * sin( radians( 101.60671 ) ) ) ) AS distance from requests
Location 1: 3.139003, 101.68685499999992
Location 2: 3.10726, 101.60671
However, the query always failed with input is out of range, which seems to be due to acos.
Anyone can provide some pointers on this?