mysql 计算两个坐标距离

方式一:st_distance_sphere 计算结果单位米

sql 复制代码
SELECT *,
st_distance_sphere(point(lng,lat),point(lng,lat)) as distance
FROM table 

mysql 版本5.7 以上

方式二:st_distance 计算结果单位是度

sql 复制代码
SELECT *,
(st_distance(point(lng,lat),point(lng4,lat))*111195/1000 ) as distance
FROM table 

st_distance 计算的结果单位是度,需要乘111195(地球半径6371000*PI/180)是将值转化为米

mysql 版本5.6 以上

测试结果

st_distance_sphere 最准确

st_distance 结果都相差有点大。(单位都是米)

在线经纬度距离计算

1.http://www.atoolbox.net/Tool.php?Id=1001

2.https://www.lddgo.net/convert/distance

3.https://tool.box3.cn/lbs.html

相关推荐
2501_9454235410 分钟前
用Matplotlib绘制专业图表:从基础到高级
jvm·数据库·python
2301_7938046911 分钟前
使用Python处理计算机图形学(PIL/Pillow)
jvm·数据库·python
哆啦A梦15887 小时前
Springboot整合MyBatis实现数据库操作
数据库·spring boot·mybatis
Zzzzmo_7 小时前
【MySQL】JDBC(含settings.xml文件配置/配置国内镜像以及pom.xml文件修改)
数据库·mysql
FirstFrost --sy8 小时前
MySQL内置函数
数据库·mysql
2401_879693878 小时前
将Python Web应用部署到服务器(Docker + Nginx)
jvm·数据库·python
reembarkation8 小时前
光标在a-select,鼠标已经移出,下拉框跟随页面滚动
java·数据库·sql
eggwyw8 小时前
MySQL-练习-数据汇总-CASE WHEN
数据库·mysql
星轨zb9 小时前
通过实际demo掌握SpringSecurity+MP中的基本框架搭建
数据库·spring boot·spring security·mp
treacle田9 小时前
达梦数据库-配置本地守护进程dmwatcher服务-记录总结
数据库·达梦数据库·达梦数据库local数据守护