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

相关推荐
JosieBook10 分钟前
【数据库】把数据优势转化为决策优势:TimechoAI时序大模型使用解析
数据库
会编程的吕洞宾1 小时前
MySQL 慢查询从5秒到50毫秒:索引失效六大场景定位与实战调优
数据库·mysql
浅念-1 小时前
MySQL 索引底层完整详解|磁盘Page|B+树推导|聚簇非聚簇索引|索引SQL操作
大数据·数据库·b树·sql·mysql·面试·职场和发展
小马过河R1 小时前
数据仓库入门:是什么、怎么做、和数据库有什么区别?
大数据·数据库·数据仓库·架构·驾驭工程·fde
Mico181 小时前
Percona Toolkit 3.5.7 完整实战笔记(从入门到精通)
mysql
小白勇闯网安圈1 小时前
Django Form 组件详解:从表单生成到 ModelForm 数据校验
数据库·django·sqlite
梦想不只是梦与想2 小时前
MySQL 数据库(二):数据类型
数据库·mysql·数据类型
野生技术架构师2 小时前
Redis 和 MySQL 如何保证数据一致性?先更新数据库还是先删缓存,延迟双删、MQ、Canal 一次讲透
数据库·redis·缓存
鸽芷咕2 小时前
SQL Server数据迁移到金仓数据库复盘:从怕性能翻车,到TPS提升60%
数据库
jason.zeng@15022073 小时前
服务器磁盘读写效率,网络吞吐量查看,mysql性能调优
服务器·网络·mysql