Jak v MySQL spočítat vzdálenost mezi 2 body? Použijeme uloženou proceduru:
DROP FUNCTION IF EXISTS `gps_distance`; DELIMITER $$ CREATE FUNCTION `gps_distance` (lat1 float, lng1 float, lat2 float, lng2 float) RETURNS float BEGIN SET lat1 = lat1 * pi() / 180; SET lng1 = lng1 * pi() / 180; SET lat2 = lat2 * pi() / 180; SET lng2 = lng2 * pi() / 180; RETURN acos ( cos(lat1)*cos(lng1)*cos(lat2)*cos(lng2) + cos(lat1)*sin(lng1)*cos(lat2)*sin(lng2) + sin(lat1)*sin(lat2) ) * 6372.795; END$$ DELIMITER ;