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