I have been trying to get location details based on miles with the below query,
SELECT * FROM (SELECT id,loc1, zipcode, latitude,longitude, (3959 * acos(cos(radians(36.0411)) * cos(radians(latitude)) * cos(radians(longitude) - radians(-115.2163)) + sin(radians(36.0411)) * sin(radians(latitude)))) AS distance FROM locations) AS distances WHERE DISTANCE < 20 ORDER BY distance
This works in my local MySQL version but the online hosting version does not work (i.e. not getting results properly) due to the MariaDB version installed there.
Ref. Find features within given coordinates and distance using MySQL