MySQL spatial extension (MySQL spatial Extensions), which allows direct processing, saving, and analysis of geolocation-related information in MySQL, appears to be the "official solution" for using MySQL to process geolocation information. But it is a pity that it does not support some of the most basic geolocation operations, such as querying all data within a radius. It does not even have a distance calculation method between two coordinate points (MySQL spatial's distance method is not supported in the 5.* version)
The official Guide's approach is this:
Glength (LINESTRINGFROMWKB (LineString (Point1, Point2)))
The processing logic of this statement is to first produce a linestring type of data through two points, and then call Glength to get the actual length of the linestring.
This is complicated, seemingly also solves the problem of distance calculation, but readers need to note is: This method calculates the distance of European space, simply speaking, it gives the result is two points in three-dimensional space in the straight line distance, not the plane flying on the Earth's trajectory, but straight through the Earth's straight line.
So if your geo-location information is stored with latitude and longitude, you can't simply use this method to do distance calculation directly.
A simple algorithm for the distance between MySQL two points