I am trying to get nearest places nearby me using following query.
select
user_address_id,
round(
( 6371* acos( least(1.0,
cos( radians(19.024808088594966) )
* cos( radians(latitude) )
* cos( radians(longitude) - radians(72.84048742388586) )
+ sin( radians(19.024808088594966) )
* sin( radians(latitude)
) ) )
), 1) as distance
from
user_address
This query works but giving difference of almost 1.5 km instead of actual. I mean if I am at point A and I want distance up to point B. Then if actual distance between point A and B is 2.0 Km but then by using above query it returns me only 0.5 Km.
Please help me in this query to get actual distance between other places and me.
Thanks in advance.
1
please show sample data and expected and actual results for that sample data