Mysql函数CONTAINS和GEOMFROMTEXT不起作用

时间:2019-02-23 08:37:42

标签: mysql

所以我有这种方法,它包含来自mysql的几何函数:

select *, (SELECT SUM(t_o.value) FROM tree_operations t_o WHERE t_o.operation_id = operations.id) operationTreeValue, (SELECT COUNT(t_o.id)  FROM `tree_operations` t_o WHERE t_o.operation_id = operations.id) operationTreeNumber, (CASE\r                          WHEN operations.type = 'pieces' THEN (SELECT GROUP_CONCAT(p.name) FROM `pieces` p WHERE p.id IN (SELECT piece_id FROM `piece_row_operations` WHERE operation_id = operations.id))\r                          WHEN operations.type = 'rows' THEN (SELECT GROUP_CONCAT(r.number) FROM `rows` r WHERE r.id IN (SELECT row_id FROM `piece_row_operations` WHERE operation_id = operations.id))\r                          END) AS typeName from `operations` where operations.id IN (SELECT t_o.operation_id FROM `tree_operations` t_o WHERE t_o.tree_id IN (SELECT t.id FROM `trees` t WHERE t.coordinates IN (Contains(GeomFromText('POLYGON(49.816472 35.971209,49.7868 35.970981,49.788668 35.947219,49.15201 35.947905,49.816472 35.971209)'))))) order by `operations`.`id` desc

但是令人惊讶的是,它在服务器上不起作用(尽管在本地完全可以) 在花费大量时间(在不同环境中运行查询等)之后,我无法得到任何可靠的答案。 我的查询有什么问题吗?还是不再起作用的功能? p.s:我的本地mysql版本是5.7,服务器是mariadb 10.2

1 个答案:

答案 0 :(得分:2)

自MySQL 5.7.6起,不再支持某些MySQL函数,如GeomFromText();

改用MariaDB @ latest && ST_GeomFromText()和ST_(其他函数)