Created
February 26, 2016 08:56
-
-
Save Foxy79/4eb7b052a55e0227a64f to your computer and use it in GitHub Desktop.
Mysql sample query finding points with distanse from current coords 500m
This file contains hidden or 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
-- 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