Skip to content

Instantly share code, notes, and snippets.

@aaronpk
Created June 29, 2010 04:37
Show Gist options
  • Save aaronpk/456800 to your computer and use it in GitHub Desktop.
Save aaronpk/456800 to your computer and use it in GitHub Desktop.
SELECT `id`, `description`, `radius`,
( 3959 * ACOS( COS( RADIANS(?) ) * COS( RADIANS( `lat` ) ) * COS( RADIANS( `lng` ) - RADIANS(?) ) + SIN( RADIANS(?) ) * SIN( RADIANS( `lat` ) ) ) ) AS `distance`
FROM `gps_places`
WHERE `startDate` <= NOW() AND `endDate` >= NOW()
HAVING `distance` <= `radius`
ORDER BY `distance`
LIMIT 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment