// 传入经纬度与数据库店家地址经纬度算出店家距离传入的地址的直线距离 // 补充为只查看 3000米 以内的店家 //$lng 经度 //$lat 纬度 $sql = ' select * from ( select id,shop_name,lng,lat,address, ROUND( 6378.138 * 2 * ASIN( SQRT( POW(SIN(('.$lat.' * PI() / 180 - lat * PI() / 180 ) / 2),2) + COS('.$lat.' * PI() / 180) * COS(lat * PI() / 180) * POW(SIN(('.$lng.' * PI() / 180 - lng * PI() / 180) / 2), 2) ) ) * 1000 ) as distance from shop where status = 1 and auser_id = 0 order by distance limit 0,10 ) as tab where distance <= 3000';
mysql 经纬度计算离一点的距离
猜你喜欢
转载自blog.csdn.net/cail_520914/article/details/78424219
今日推荐
周排行