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

相关推荐
CoderYanger1 小时前
Java EE 进阶:13. Spring事务和事务传播机制(第二弹)
java·开发语言·数据库·spring boot·后端·spring·java-ee
FungLeo4 小时前
FengCMS · PHP+MySQL 升级实录 ·双数据库验证:MySQL8.4与MariaDB 10.11的兼容矩阵
数据库·mysql·php·工程实践·fengcms
XW9632586 小时前
除湿机行业组织能力与人才地图报告
大数据·服务器·网络·数据结构·数据库·人工智能
Decay__7 小时前
PostgreSQL 性能调优方法论 —— pg_stat_statements、EXPLAIN ANALYZE、瓶颈定位流程与参数基线
运维·数据库·sql·postgresql
前端兰博9 小时前
分库分表
数据库
智能收银研究所10 小时前
收银系统选型对比:美团、客如云、拉卡拉、收钱吧各适合什么门店
java·前端·数据库
有个傻瓜11 小时前
手机号明明查不到,注册却提示“已存在“:MyBatis-Plus 逻辑删除与唯一索引冲突排错复盘与五种方案实测
mysql·mybatis-plus·故障排查·唯一索引·逻辑删除
七夜zippoe11 小时前
金仓 Kingbase 安装与 Java 连接(保姆级):从装库到 JDBC 跑通全记录
java·数据库·jdbc·kingbase·金仓
FungLeo12 小时前
FengCMS · PHP+MySQL 升级实录 · 留言模块的六项问题:未审核进公开列表、旧回复覆盖、批量删除恢复
android·mysql·php·工程实践·fengcms
stormsha12 小时前
中文路径让 MySQL 起不来:Failed to find valid data directory 与 Illegal byte sequence
运维·数据库·mysql