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

相关推荐
C'ᴇsᴛ.小琳 ℡1 分钟前
高性能NoSQL
数据库·nosql
i220818 Faiz Ul34 分钟前
动漫商城|基于springboot + vue动漫商城系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·论文·毕设·动漫商城系统
iNgs IMAC42 分钟前
redis 使用
数据库·redis·缓存
bearpping1 小时前
MySQL压缩版安装详细图解
android·mysql·adb
TDengine (老段)2 小时前
TDengine IDMP 可视化 —— 面板
大数据·数据库·人工智能·物联网·ai·时序数据库·tdengine
卓怡学长2 小时前
m315基于java的水果网上商城的开发与设计
java·数据库·spring·tomcat·maven·intellij-idea
刘~浪地球2 小时前
Redis 从入门到精通(八):有序集合操作详解
数据库·chrome·redis
fe7tQnVan3 小时前
MyBatis-动态sql与高级映射
数据库·sql·mybatis
计算机安禾3 小时前
【数据结构与算法】第28篇:平衡二叉树(AVL树)
开发语言·数据结构·数据库·线性代数·算法·矩阵·visual studio
道清茗4 小时前
【MySQL知识点问答题】高级复制技术
数据库·mysql