Skip to content

Instantly share code, notes, and snippets.

@daniel7byte
Created February 6, 2017 19:17
Show Gist options
  • Save daniel7byte/075843c3effc70405e13796a1a6f38fc to your computer and use it in GitHub Desktop.
Save daniel7byte/075843c3effc70405e13796a1a6f38fc to your computer and use it in GitHub Desktop.
Author: victor-basurto
/* Mi Ubicacion Actual */
/* Lat: 3.4227857999999998, Lng: -76.55079080000002 */
SELECT id, latitud, longitud, SQRT(
POW(69.1 * (latitud - '3.4227857999999998'), 2) +
POW(69.1 * ('-76.55079080000002' - longitud) * COS(latitud / 57.3), 2)) AS distance
FROM cali_sucursales HAVING distance < 0.5;
/* Donde 0.5 es el rango en millas */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment