distance entre deux coordonnées en mysql

22/07/2016
$lat = 48.833297;
$lng = 2.298454;

// pour des miles : 3959
// pour des km : 6371

$sql = 'SELECT 
  name, 
   ( 6371 * acos( cos( radians('.$lat.') ) * cos( radians( locations.lat ) ) 
   * cos( radians(locations.lng) - radians('.$lng.')) + sin(radians('.$lat.')) 
   * sin( radians(locations.lat)))) AS distance 
FROM locations 
WHERE active = 1 
HAVING distance < 10 
ORDER BY distance'

Raccourcis