I am using this SQL query to get data that is nearest to GPS coordinates.
SELECT geo_latitude, geo_longitude, geo_name, geo_country_code AS country,
(DEGREES(
ACOS(
SIN(RADIANS(47.470779)) * SIN(RADIANS(geo_latitude)) +
COS(RADIANS(47.470779)) * COS(RADIANS(geo_latitude)) *
COS(RADIANS(-87.890699 - geo_longitude))
)
) * 60 * 1.1515)
AS distance FROM `MyDatabase`.`allCountries` ORDER BY distance ASC LIMIT 20 ;
This query retrieves all the data irrespective of the distance. I would like it to display the data only within a radius of 10 miles. How can i achieve this?