虽然,mariadb 可以替代 mysql,但某些函数,mariadb 是没有的。比如,ST_Distance_Sphere
。当然,mariadb 拥有的函数 mysql 也不一定有。
请参考:
https://mariadb.com/kb/en/library/function-differences-between-mariadb-102-and-mysql-57/
https://mariadb.com/kb/en/library/mysqlmariadb-spatial-support-matrix/
看着 ST_Distance_Sphere 很好用,却不能用。那也没办法,可以试试 ST_DISTANCE
函数。
eg:
``
select ST_Distance_Sphere(ST_GeomFromText('Point(115.452081 30.486021)'), position) as distance from ball_invitations
select (ST_Distance(GeomFromText('Point(115.452081 30.486021)'), position) / 0.0111195) as distance from ball_invitations
``
参考
https://mariadb.com/kb/en/library/st_distance/
https://dev.mysql.com/doc/refman/5.7/en/spatial-convenience-functions.html
http://www.innomysql.com/mysql_gis_lbs/
https://blog.csdn.net/zhouzhiwengang/article/details/53612481