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

相关推荐
reasonsummer1 分钟前
【教学类-160-11】20260419 AI视频培训-练习011“豆包AI视频《佛源植语》+豆包图片风格:无(关键词:藏传唐卡)”
数据库·音视频·豆包
瀚高PG实验室19 分钟前
pgroonga全文检索插件的BUG
数据库·postgresql·bug·瀚高数据库
Rick199322 分钟前
mysql 慢查询如何快速定位
数据库·mysql
2401_8330336231 分钟前
c++如何实现简单的文件签名验证_HMAC-SHA1算法应用【进阶】
jvm·数据库·python
qq_3926906639 分钟前
SQL报表查询标准规范_SQL书写规范优化
jvm·数据库·python
Vect__42 分钟前
MySQL的数据类型和约束
android·数据库·mysql
八秒记忆的老男孩1 小时前
Sentinel5P的L1B级数据预处理(BD7和BD8)【20260427】
数据库·redis·缓存
ChoSeitaku1 小时前
5.MySQL表的约束|空属性|默认值|列描述|主键|自增长|唯一键|外键
android·数据库·mysql
S1998_1997111609•X1 小时前
滄集/㞯鎩.赫量被恶意篡改?|\^*仺\~:sall,sql=㶏齾bci.ji.app_sql=-heart{TCP.box}‘雧……㞋
网络·数据库·网络协议·百度·微信
2301_803875611 小时前
c++如何通过重定向streambuf流捕获标准错误输出并记录到运行日志【详解】
jvm·数据库·python