Last active
August 10, 2019 14:00
-
-
Save mfcodeworks/29cdae9876f4c3d4cbe9b88e655b8651 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT id, address, datetime, price, ROUND(6371 * acos(cos(radians(1.329380)) * cos(radians(event_lat)) * cos(radians(event_lng) - radians(103.775595)) + sin(radians(1.329380)) * sin(radians(event_lat))), 3) as distance | |
FROM jobs | |
WHERE (6371 * acos(cos(radians(1.329380)) * cos(radians(event_lat)) * cos(radians(event_lng) - radians(103.775595)) + sin(radians(1.329380)) * sin(radians(event_lat)))) < 50 | |
ORDER BY distance DESC; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Select details and haversine formula in kilometres rounded to nearest metre, from jobs table, where the radius given by haversine is less than 50km, sort by distance descending