Created
September 21, 2012 14:49
-
-
Save jonsherrard/3761922 to your computer and use it in GitHub Desktop.
horrible sql
This file contains 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($lat)*sin(radians(event_latitude)) + cos($lat)*cos(radians(event_latitude))*cos(radians(event_longitude)-$lon))*$R As distance | |
From ( | |
Select search_view.*, images.image_url | |
From search_view, images | |
Where search_view.event_image_id = images.image_id | |
AND event_start > ? | |
And event_latitude>$min_lat And event_latitude<$max_lat | |
And event_longitude>$min_lon And event_longitude<$max_lon | |
) As FirstCut | |
Where acos(sin($lat)*sin(radians(event_latitude)) + cos($lat)*cos(radians(event_latitude))*cos(radians(event_longitude)-$lon))*$R < $rad | |
Group by event_url | |
Order by event_start ASC"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment