MySQL 计算两个经纬度之间的距离

SQL如下

select (ST_DISTANCE(POINT(longitude,latitude), POINT(113.64010000, 34.72468000)) 
* (6371000 * PI() / 180))/1000 as distance ,latitude ,longitude 
from tableName
where 1=1
order by distance asc

结果如下

distance         |latitude   |longitude   |
-----------------+-----------+------------+
              0.0|34.72468000|113.64010000|
38.40928986231956|34.39656649|113.74807501|
78.09504308669169|34.79463015|114.33893347|
96.13558701354424|34.50358227|114.47591924|
653.6566941870128|39.91652700|

最后修改于 2023-10-12 19:22:21
如果觉得我的文章对你有用,请随意赞赏
扫一扫支付
上一篇