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

相关推荐
影寂ldy10 分钟前
C# 多线程进阶知识点(线程优先级、多委托传参、线程锁、死锁)
开发语言·数据库·c#
Leon-Ning Liu18 分钟前
【真实经验分享】Oracle RAC + ASM 下 db_recovery_file_dest 路径格式导致 ORA-01261 无法 NOMOUNT
数据库·oracle
QN1幻化引擎40 分钟前
# DalinX V8 灵鉴 V2:12维意识评测框架 —— 从 Tononi IIT 到 Friston FEP 的理论统一
数据库·人工智能·算法·机器学习·数据挖掘·agi
聚美智数1 小时前
常见疾病查询-疾病症状—疾病介绍-疾病大全-疾病治疗查询API接口介绍
android·java·数据库
观远数据1 小时前
经营闭环的最后一公里:从看见问题到解决问题之间还差什么
java·开发语言·数据库
延凡科技1 小时前
数字孪生全域智慧园区综合可视化运营平台|延凡科技智园视界解决方案
数据库·人工智能·物联网·数据可视化
SelectDB技术团队1 小时前
大规模集群治理:Apache Doris / SelectDB 的 CCR 无感升级、Colocate Join 与 Bitmap 精确去重
大数据·数据库·人工智能·agent·olap·selectdb·集群治理
qq_212838971 小时前
后端Node.js + MySQL,前端Html+js,Nginx反向代理快速部署WEB项目
前端·mysql·node.js
指剑1 小时前
AWS RDS MySQL 8.0 升级到 8.4 完整操作指南
mysql·云计算·aws
卓怡学长8 小时前
w255基于springboot仓库管理系统
java·数据库·spring boot·spring·intellij-idea