How to use st_distance of mysql5.6 to sort by distance
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