直接看SQL
//调用mysql距离函数,查经数据库经纬度和条件之间的距离。
SELECT *,(st_distance(POINT(longitude,latitude),POINT(#{longitude}, #{latitude}))/ 0.0111)*1000 as distance
FROM shop_store
//条件查询(距离是否小于数据库储存的距离范围)
HAVING distance <= sale_range
ORDER BY distance
LIMIT 0,1
//调用mysql距离函数,查经数据库经纬度和条件之间的距离。
SELECT *,(st_distance(POINT(longitude,latitude),POINT(#{longitude}, #{latitude}))/ 0.0111)*1000 as distance
FROM shop_store
//条件查询(距离是否小于数据库储存的距离范围)
HAVING distance <= sale_range
ORDER BY distance
LIMIT 0,1
评论区