Skip to content

Instantly share code, notes, and snippets.

@silentsudo
Created December 1, 2021 04:56
Show Gist options
  • Save silentsudo/6d1a96c7fd3de5b4a15a65c5b6ebef9b to your computer and use it in GitHub Desktop.
Save silentsudo/6d1a96c7fd3de5b4a15a65c5b6ebef9b to your computer and use it in GitHub Desktop.
SELECT
id,
address,
(6371 *
ACOS(COS(RADIANS(12.972442)) * COS(RADIANS(latitude)) * COS(RADIANS(longitude) -
RADIANS(77.580643)) + SIN(RADIANS(12.972442)) * SIN(RADIANS(latitude)))) AS distance
FROM
address
HAVING distance < 5
ORDER BY distance
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment