MySQL Great Circle Distance (Haversine formula)

前端 未结 9 1572
栀梦
栀梦 2020-11-21 06:53

I\'ve got a working PHP script that gets Longitude and Latitude values and then inputs them into a MySQL query. I\'d like to make it solely MySQL. Here\'s my current PHP Cod

9条回答
  •  温柔的废话
    2020-11-21 07:11

    calculate distance in Mysql

     SELECT (6371 * acos(cos(radians(lat2)) * cos(radians(lat1) ) * cos(radians(long1) -radians(long2)) + sin(radians(lat2)) * sin(radians(lat1)))) AS distance
    

    thus distance value will be calculated and anyone can apply as required.

提交回复
热议问题