【发布时间】:2016-01-13 16:51:39
【问题描述】:
其实很简单,就是不知道怎么做。
我有一张桌子:
table locations
location_id coordinates name
-------------------------------------
当我从设备接收到纬度和经度时,我将其存储在 mysql 中 POINT(Long, Lat) 类型的变量中。
我正在尝试获取 Locations 表中距离小于或等于 8 米的所有行。
我的查询如下:
SELECT * FROM locations where st_distance_sphere(@userCoords, @pt1) <= 8;
我知道这个查询是错误的,因为@pt1 与列坐标无关。如何隔离坐标列中的特定值并返回匹配的行列表?
st_distance_sphere() 函数只计算两个坐标之间的距离并返回一个数字。
提前感谢您!
【问题讨论】: