-- 計算兩個地點的球面距離,單位千米
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;