Mysql 基于距离返回匹配的sql行
其实很简单,我只是不知道怎么做 我有一张桌子:Mysql 基于距离返回匹配的sql行,mysql,sql,database,gis,Mysql,Sql,Database,Gis,其实很简单,我只是不知道怎么做 我有一张桌子: table locations location_id coordinates name ------------------------------------- 当我从设备接收到纬度和经度时,我将其存储在mysql中POINT(Long,Lat)类型的变量中 我试图获取位置表中距离小于或等于8米的所有行 我的质询如下: SELECT * FROM locations where st_distance_sphere(@user
table locations
location_id coordinates name
-------------------------------------
当我从设备接收到纬度和经度时,我将其存储在mysql中POINT(Long,Lat)类型的变量中
我试图获取位置表中距离小于或等于8米的所有行
我的质询如下:
SELECT * FROM locations where st_distance_sphere(@userCoords, @pt1) <= 8;
从st_distance_sphere(@userCoords,@pt1)所在的位置选择*只需放置列而不是@pt1
(假设列类型为点):
选择*
从地点
其中,st_distance_sphere(@userCoords,coordinates)只需放置列,而不是@pt1
(假设列类型为点):
选择*
从地点
这里是距离球(@userCoords,坐标)救世主。谢谢你帮助一个新手:DSavior。谢谢你帮了一个新手
SELECT *
FROM locations
where st_distance_sphere(@userCoords, coordinates) <= 8;