In my previous post about geo-spatial search in MySQL I described (along with other things) how to use geo-distance functions. In this post I will describe the geo-spatial distance functions in more details.
If you need to calculate an exact distance between 2 points on Earth in MySQL (very common for geo-enabled applications) you have at least 3 choices.
- Use stored function and implement haversine formula
- Use UDF (user defined function) for haversine (see below)
- In MySQL 5.6 you can use st_distance …