公式:

第一点经纬度:lng1 lat1
第二点经纬度:lng2 lat2

 

round(6378.138*2*asin(sqrt(pow(sin((lat1*pi()/180-lat2*pi()/180)/2),2)+cos(lat1*pi()/180)*cos(lat2*pi()/180)*  
pow(sin( (lng1*pi()/180-lng2*pi()/180)/2),2)))*1000)

 

sql语句:

SELECT *, ROUND(6378.138*2*ASIN(SQRT(POW(SIN((lat1*PI()/180-lat2*PI()/180)/2),2)+COS(lat1*PI()/180)*COS(lat2*PI()/180)*POW(SIN((lng1*PI()/180-lng2*PI()/180)/2),2)))*1000) AS distance FROM b_cerify ORDER BY distance ASC