Created
November 30, 2011 11:04
-
-
Save davesherratt/1408695 to your computer and use it in GitHub Desktop.
mysql radius
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 asciiname,latitude,longitude, acos(SIN( PI()* 40.7383040 /180 )*SIN( PI()*latitude/180 ) | |
)+(cos(PI()* 40.7383040 /180)*COS( PI()*latitude/180) *COS(PI()*longitude/180-PI()* -73.99319 /180) | |
)* 3963.191 AS distance | |
FROM allcountries | |
WHERE 1=1 | |
AND 3963.191 * ACOS( (SIN(PI()* 40.7383040 /180)*SIN(PI() * latitude/180)) + | |
(COS(PI()* 40.7383040 /180)*cos(PI()*latitude/180)*COS(PI() * longitude/180-PI()* -73.99319 /180)) | |
) < = 1.5 | |
ORDER BY 3963.191 * ACOS( | |
(SIN(PI()* 40.7383040 /180)*SIN(PI()*latitude/180)) + | |
(COS(PI()* 40.7383040 /180)*cos(PI()*latitude/180)*COS(PI() * longitude/180-PI()* -73.99319 /180)) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment