Created
October 5, 2011 00:22
-
-
Save michaelaguiar/1263246 to your computer and use it in GitHub Desktop.
SQL - Calculate Distance
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
| SELECT *,(((acos(sin((".$latitude."*pi()/180)) * sin((`Latitude`*pi()/180))+cos((".$latitude."*pi()/180)) * cos((`Latitude`*pi()/180)) * cos(((".$longitude."- `Longitude`)*pi()/180))))*180/pi())*60*1.1515) as distance FROM `TABLE` HAVING distance <= ".$distance; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment