Skip to content

Instantly share code, notes, and snippets.

@urieljuliatti

urieljuliatti/Nearby

Created Sep 12, 2013
Embed
What would you like to do?
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
You can’t perform that action at this time.