Skip to content

Instantly share code, notes, and snippets.

@naneri
Created May 20, 2017 10:01
Show Gist options
  • Save naneri/019ec67bffb1ebcf66688593e3c64024 to your computer and use it in GitHub Desktop.
Save naneri/019ec67bffb1ebcf66688593e3c64024 to your computer and use it in GitHub Desktop.
$fLat is the searchers latitude and $fLon the searchers longitude.
SELECT
`id`,
`name`
FROM
`stations`
WHERE
ACOS( SIN( RADIANS( `latitude` ) ) * SIN( RADIANS( $fLat ) ) + COS( RADIANS( `latitude` ) )
* COS( RADIANS( $fLat )) * COS( RADIANS( `longitude` ) - RADIANS( $fLon )) ) * 6380 < 10
ORDER BY
`distance`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment