查询附近的点sql语句

原理:

统计微信公众号获取位置接口,获取到位置和经纬度,用此经纬度ajax读取数据库中的点的数据,更新数据。

//通过sql语句查询距离5公里之内的门店
    $sql = "select * from (select shop_id,shop_name,shop_tel,shop_position,shop_logo,  ROUND(6378.138*2*ASIN(SQRT(POW(SIN(($latitude*PI()/180-`shop_wei`*PI()/180)/2),2)+COS($latitude*PI()/180)*COS(`shop_wei`*PI()/180)*POW(SIN(($longitude*PI()/180-`shop_jing`*PI()/180)/2),2)))*1000) AS distance from sp_shop order by distance ) as a where a.distance<=5000";

猜你喜欢

转载自blog.csdn.net/li2314/article/details/82629526