Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to use st_distance of mysql5.6 to sort by distance

Shulou Source: shulou.com Published: 2022-06-02 07:33:05 10月01日 Update

This article mainly explains "how to use the st_distance implementation of mysql5.6 to sort by distance". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to use the st_distance implementation of mysql5.6 to sort by distance".

For the current location (113.858202, 22.583819), you need to query the community within 1000 meters of my neighborhood and install it in order from near to far.

SELECT

S.id,s.name,s.lng,s.lat

Round ((st_distance (point (lng, lat), point (113.858202) 22.583819) / 0.0111) * 1000) AS distance

FROM

Wlsq_base.lt s

HAVING distance

Tags: Distance ranking learning content location location community that is ideas situations articles more knowledge knowledge points articles follow questions order meter former place Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Redmi NVidia Shulou Information Linux