Mysql st_distance_sphere 计算两坐标点距离

-- 计算两个地点的球面距离,单位千米
select city_name, round(st_distance_sphere(point(118.35, 24.49),point(lng, lat))/1000,2), update_time as distance from tb_vip_geo order by update_time

-- 查询与第一个坐标点(118.35, 24.49)相距小于500千米的坐标点
select city_name, round(st_distance_sphere(point(118.35, 24.49),point(lng, lat))/1000,2) as distance, update_time 
from tb_vip_geo 
HAVING distance > 0 and distance < 500
ORDER BY distance;

 

posted on 2020-05-13 14:20  Ruthless  阅读(5598)  评论(0编辑  收藏  举报