0

mysql计算经纬度距离

mysql中计算经纬度方法

select * ,3956*2*asin(sqrt(power(sin((122.4058-abs(dest.lat))*pi()/180/2),2)+cos(122.4058/180)*cos(abs(dest.lat)*pi()/180)*power(sin((37.7907-dest.lon)*pi()/180/2),2))) as distance from sp_zxcplace dest HAVING distance<10000 order by distance

A5798FB2-258F-46D5-8BCF-AF0F5BB2E641

 

 

Mysql根据经纬度算距离返回米

亲测ok

SELECT pId,name,lon,lat, ROUND(6378.138*2*ASIN(SQRT(POW(SIN((34.3574030000*PI()/180-lat*PI()/180)/2),2)+COS(34.3574030000*PI()/180)*COS(lat*PI()/180)*POW(SIN((108.9263460000*PI()/180-lon*PI()/180)/2),2)))*1000) AS distance  FROM sp_zxcplace HAVING distance<10000 ORDER BY distance

天边的星星