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

相关推荐
神王宝宝 王者小学2 小时前
HBase: 看上去很美
大数据·数据库·hbase
io无心3 小时前
Shardingsphere5分库分表
数据库·mysql
wWYy.3 小时前
Mysql:主键索引 唯一索引 普通索引 前缀索引
数据库·mysql
宝杰X74 小时前
Android Room3 多平台数据库
android·数据库
sky_8106137 小时前
Oracle ERP 各模块业务管理功能及底层表说明
数据库·oracle
YMatrix 官方技术社区8 小时前
CittaBase vs. Neo4j :原生图性能实测与混合检索实践
数据库·功能测试·ymatrix
闲猫9 小时前
LangChain / Integrations / Integrations by component / Tool
java·数据库·langchain
xqqxqxxq10 小时前
SQL 连接查询技术笔记
数据库·笔记·sql
在世修行10 小时前
Windows 上 Docker Desktop 部署 MySQL + TDengine 全过程(含 WSL 报错与镜像加速排障实战)
windows·mysql·docker·tdengine
Databend10 小时前
从万亿级大模型到全线应用:Databend Cloud 助力头部 AI 企业构建全链路 Trace 数据管道
大数据·数据库·sql