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

  • local MySQL version (5.7.33) and online hosting MySQL details as Server type: MariaDB, Server version: 10.5.20-MariaDB-cll-lve-log - MariaDB Server Commented Sep 8, 2023 at 13:19


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.