MYSQL ranks the distance between two latitude and longitude in order of proximity and distance
select *,(2 * 6378.137* ASIN(SQRT(POW(SIN(PI()*(111.86141967773438-lat)/360),2)+COS(PI()*33.07078170776367/180)* COS(lat * PI()/180)*POW(SIN(PI()*(33.07078170776367-lng)/360),2)))) as juli from `area`
order by juli asc limit 0,20
That’s pretty much it. Make a note But I think this is still very slow, because my coordinates are all obtained through baidu, my idea is that it is better to be able to convert to plane coordinates, so it is easier to calculate