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

相关推荐
程序猿追2 小时前
换场倒计时的暂停、重置与到点回调在 HarmonyOS 7 上怎么处理
运维·服务器·数据库·harmonyos
@forever@4 小时前
【MySQL】数据库基础、架构与存储引擎详解
数据库·mysql·架构
轩轩曲觞阁4 小时前
MySQL基础——数据类型
数据库·mysql
jnrjian5 小时前
Oracle 19C LogMiner 分析 Supplemental Log Groups
数据库·oracle
小小测试开发6 小时前
rsync 源路径少一个斜杠,--delete 删的就不是你以为的那一层
java·前端·数据库·人工智能
泓度科技7 小时前
单表百万数据查询慢 规范索引设计实现毫秒级响应
mysql·性能调优·数据库优化·索引设计·中小实体系统
小敬爱吃饭7 小时前
PgHero轻量PostgreSQL监控:Docker部署、连接统计与执行计划
数据库·docker·postgresql
2401_891409267 小时前
期权全量合约历史数据:分钟/Tick/日级/L2五档字段清单
数据库
海宇服务8 小时前
零信任架构实战:基于海宇企业司法涉诉构建自动化分包商准入合规审查网关
数据库·人工智能·架构·自动化
W_son8 小时前
数据库归档模式开启与备份作业配置实战
数据库·oracle·达梦数据库