一、方式一
st_distance 计算的结果单位是度,需要乘111195(地球半径6371000*PI/180)是将值转化为米。 SELECT *, (st_distance(point(lng,lat),point(116.3424590000,40.0497810000))*111195/1000 ) as juli FROM table ORDER BY juli ASC
二、方式二
select *, 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 juli from table order by juli asc