MySQL版本无法执行几何查询

标签 mysql mariadb

如果我运行这个查询

SELECT region_id FROM shape_region WHERE ST_Within(point(-117.10480, 32.72204),shape_region.shape)=1

MySQL MariaDB version 10.1.13-MariaDB上,没有问题。

但是在 MySQL 版本 5.7.16-0ubuntu0.16.04.1 上我得到这个错误

Binary geometry function st_within given two geometries of different srids: 0 and 1, which should have been identical.

我不明白这个错误,有没有我可以在这个版本的 MySQL 上使用的类似查询?

最佳答案

在此链接找到答案

https://bugs.mysql.com/bug.php?id=79282

适用于 MySQL 和 MariaDB 的兼容查询:

SELECT region_id FROM shape_region WHERE ST_Contains( SHAPE, ST_GeomFromText( 'POINT(-122.392128 37.795653)', 1 ) )

如链接中所述

You can't compare a shape in one spatial reference system (SRID 1) with a point in another spatial reference system (SRID 0). The POINT() function[1] will always return a point in SRID 0, which is the unitless, Cartesian default spatial reference system.

In order to do the intended comparison, the point has to be in the same spatial reference system as the shape. E.g., use the SRID parameter of ST_GeomFromText()[2]:

关于MySQL版本无法执行几何查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42424864/

相关文章:

java - Mysql 使用 hibernate 根据请求进行备份

mysql - 如何处理并发(多个用户编辑相同数据)- VB.NET 特色 MySQL

mysql - MariaDB ER_TRUNCATED_WRONG_VALUE : Incorrect datetime value for values before 1970-01-01 00:00:00

database - 多主到单从复制

mysql - 如何重命名 mariaDB 中的列名

mysql - 具有 SUM 中条件的 DQL

php - 检查产品是否已购买

php - 需要一个食谱表和类别表,以便一个食谱可以有多个类别

mysql - 使用mysqladmin设置数据库字符集的问题

linux - 如何创建自定义 maria DB docker 镜像