mysql使用st_distance_sphere函数报错Incorrect arguments to st_distance_sphere

最近发现执行mysql st_distance_sphere报错了。

报错的信息是Incorrect arguments to st_distance_sphere。

最开始以为是跟mysql的版本有关系,所以看了下自己本地的mysql版本,执行一下sql

复制代码
select version();

发现自己本地的mysql版本是

5.7.30

这个版本是支持st_distance_sphere函数的。

但是,仍旧报错,后来考虑使用st_distance,st_distance函数执行是不会报错的。

查了下,st_distance_sphere是比st_distance相对更精确些,所以就抱着精确的心理,看看如何解决执行st_distance_sphere函数报错的问题。

最后,发现了原因,在处理数据将数据插入到mysql的脚本中

复制代码
`location` point NOT NULL

location的字段存储的point数据,没有按照要求存储,错误的存储成POINT(纬度 经度),正确的应该存储城经度在前,纬度在后,正确的格式数据如下图

其实英文原文的文档中也有对这个描述

SQL Error (1210): Incorrect arguments to st_distance_sphere

The geometry arguments should consist of points that specify (longitude, latitude) coordinate values: Longitude and latitude are the first and second coordinates of the point, respectively. Both coordinates are in degrees

相关推荐
睡不醒男孩0308239 分钟前
自建 Prometheus+Grafana 与 CLUP 深度监控 PG 集群有什么区别?
数据库·oracle
就叫_这个吧17 分钟前
IDEA Mybatis xml文件,实现sql语句联想,自动填入补充
xml·mysql·intellij-idea·mybatis
AOwhisky18 分钟前
Redis 学习笔记(第四期):高可用与集群(哨兵 + Cluster + 容器化)
linux·运维·数据库·redis·笔记·学习·缓存
猫猫聚会Ing37 分钟前
数据库设计 Prompt 提示词 - 构建与迭代
数据库
上海云盾-小余39 分钟前
源站隐藏实战:规避裸 IP 被直接攻击的完整方案
数据库·网络协议·tcp/ip
微学AI2 小时前
时序大模型 TimechoAI 赋能工业时序数据底层技术优势与实操
数据库·大模型·时序大模型
北顾笙9802 小时前
MYSQL-day03
数据库·sql·mysql
MXsoft6182 小时前
**混合云统一监控实践:私有云+公有云的一体化运维方案**
运维·网络·数据库
瀚高PG实验室2 小时前
java中间件无法连接数据库
java·数据库·中间件·瀚高数据库
ULIi096kr2 小时前
MySQL大表优化终极方案:单表数据量上限、卡顿解决、分表分库实战教程
数据库·mysql