Skip to content

Instantly share code, notes, and snippets.

@Foxy79
Created February 26, 2016 08:56
Show Gist options
  • Save Foxy79/4eb7b052a55e0227a64f to your computer and use it in GitHub Desktop.
Save Foxy79/4eb7b052a55e0227a64f to your computer and use it in GitHub Desktop.
Mysql sample query finding points with distanse from current coords 500m
-- 55.88846600 = current latitude
-- 37.44916300 = current longitude
SELECT Title, ROUND( 6371000 * acos( cos( radians('55.88846600') ) * cos( radians( Lat ) ) * cos( radians( Lng ) - radians('37.44916300') ) + sin( radians('55.88846600') ) * sin( radians( Lat ) ) ) ) AS distance FROM Points HAVING distance < 500 OR distance IS NULL ORDER BY distance LIMIT 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment