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;

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM