Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --- Where:
- --- $LATITUDE = the latitude of the start point e.g 7.08594109039762;
- --- $LONGITUDE = the longitude of the start point e.g 286.95225338731285;
- --- $DISTANCE_KILOMETERS = your radius of search in Kilometers e.g 150
- SELECT * FROM (
- SELECT *,
- (
- (
- (
- acos(
- sin(( $LATITUDE * pi() / 180))
- *
- sin(( `latitud_fieldname` * pi() / 180)) + cos(( $LATITUDE * pi() /180 ))
- *
- cos(( `latitud_fieldname` * pi() / 180)) * cos((( $LONGITUDE - `longitude_fieldname`) * pi()/180)))
- ) * 180/pi()
- ) * 60 * 1.1515 * 1.609344
- )
- as distance FROM `myTable`
- ) myTable
- WHERE distance <= $DISTANCE_KILOMETERS
- LIMIT 15;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement