select *, acos(cos(lat * (PI()/180)) * cos(lon * (PI()/180)) * cos(d_lat * (PI()/180)) * cos(d_lon * (PI()/180)) + cos(lat * (PI()/180)) * sin(lon * (PI()/180)) * cos(d_lat * (PI()/180)) * sin(d_lon * (PI()/180)) + sin(lat * (PI()/180)) * sin(d_lat * (PI()/180)) ) * 3959 as Dist from TABLE_NAME having Dist < radius order by Dist
Your Location (기준의 위도, 경도) :
lat : 위도
lon : 경도
Location in Data (데이터의 위도,경도) :
d_lat : 데이터의 위도
d_lon : 데이터의 경도
Earth radius (지구 반지름) :
3,959 in miles
6,371 in km