1DELIMITER |
2CREATE PROCEDURE getNearestCities(IN cityID INT)
3 BEGIN
4 DECLARE cityLat FLOAT;
5 DECLARE cityLng FLOAT;
6 SET cityLat = SELECT cities.lat FROM cities WHERE cities.id = cityID;
7 SET cityLng = SELECT cities.lng FROM cities WHERE cities.id = cityID;
8 SELECT *, HAVERSINE(cityLat,cityLng, cities.lat, cities.lng) AS dist FROM cities ORDER BY dist LIMIT 10;
9 END |
10