Created
March 8, 2018 16:20
-
-
Save RanKey1496/1df26d0444ea4ad1426abff592874801 to your computer and use it in GitHub Desktop.
Geospatial query that search properties nearby to a point
This file contains hidden or 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 | |
prom.id, p.id, p.direccion, p.latitud, p.longitud, | |
( | |
6371 * | |
ACOS( | |
COS( RADIANS( 6.250020 ) ) * | |
COS( RADIANS( `latitud` ) ) * | |
COS( | |
RADIANS( `longitud` ) - RADIANS( -75.568510 ) | |
) + | |
SIN(RADIANS( 6.250020 )) * | |
SIN(RADIANS(`latitud`)) | |
) | |
) `distance` | |
FROM | |
Propiedad p | |
INNER JOIN Promocion prom ON p.id = prom.id_propiedad | |
HAVING | |
`distance` < 1 | |
ORDER BY | |
`distance` ASC | |
LIMIT 10 OFFSET 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment