Advertisement
abidkhan484

Untitled

Jan 8th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. --- Where:
  2. --- $LATITUDE = the latitude of the start point e.g 7.08594109039762;
  3. --- $LONGITUDE = the longitude of the start point e.g 286.95225338731285;
  4. --- $DISTANCE_KILOMETERS = your radius of search in Kilometers e.g 150
  5.  
  6. SELECT * FROM (
  7. SELECT *,
  8. (
  9. (
  10. (
  11. acos(
  12. sin(( $LATITUDE * pi() / 180))
  13. *
  14. sin(( `latitud_fieldname` * pi() / 180)) + cos(( $LATITUDE * pi() /180 ))
  15. *
  16. cos(( `latitud_fieldname` * pi() / 180)) * cos((( $LONGITUDE - `longitude_fieldname`) * pi()/180)))
  17. ) * 180/pi()
  18. ) * 60 * 1.1515 * 1.609344
  19. )
  20. as distance FROM `myTable`
  21. ) myTable
  22. WHERE distance <= $DISTANCE_KILOMETERS
  23. LIMIT 15;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement