sql get the distance between two points

select * from (select
(2*6378137*SQRT((sin(((a.latitude*PI()/180.0)-b.lat1)/2.0))* (sin(((a.latitude*PI()/180.0)-b.lat1)/2.0))+COS(b.lat1)*COS(a.latitude*PI()/180.0)*((sin(((a.longitude*PI()/180.0)-b.long1)/2.0)))*((sin(((a.longitude*PI()/180.0)-b.long1)/2.0))))) as dis

from user_latitude_longitude a,
(SELECT (b.latitude*PI()/180.0) as lat1,(b.longitude*PI()/180.0) as long1 from user_latitude_longitude b where b.userId=28) b
where a.userId !=  28 ) f where dis >500 order by dis desc

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=327063418&siteId=291194637