Created
September 12, 2013 13:03
-
-
Save urieljuliatti/6536929 to your computer and use it in GitHub Desktop.
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 *, | |
( 3959 * acos( cos( radians('#{latitude}') ) * | |
cos( radians( latitude ) ) * | |
cos( radians( longitude ) - | |
radians('#{longitude}') ) + | |
sin( radians('#{latitude}') ) * | |
sin( radians( latitude ) ) ) ) | |
AS distance, a_b.name as neighbourhood_name FROM address_neighbourhood_users INNER JOIN address_neighbourhoods AS a_b ON a_b.neighbour_code = address_neighbourhood_users.address_neighbourhood_code AND ( 3959 * acos( cos( radians('#{latitude}') ) * | |
cos( radians( latitude ) ) * | |
cos( radians( longitude ) - | |
radians('#{longitude}') ) + | |
sin( radians('#{latitude}') ) * | |
sin( radians( latitude ) ) ) ) < '5' ORDER BY address_neighbourhood_users.id ASC |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment