Skip to content

Instantly share code, notes, and snippets.

@antoniodipinto
Created August 30, 2016 15:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antoniodipinto/db9b683b267d64549a9e612e74e9040b to your computer and use it in GitHub Desktop.
Save antoniodipinto/db9b683b267d64549a9e612e74e9040b to your computer and use it in GitHub Desktop.
This query will return the distance between two points
#This query will return the distance between two points
SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) * cos( radians( lng ) - radians(-122) ) + sin( radians(37) ) * sin( radians( lat ) ) ) )
AS distance
FROM markers
HAVING distance < 25
ORDER BY distance LIMIT 0 , 20;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment