Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6109845
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:26:59+00:00 2026-05-23T14:26:59+00:00

Options $lat = ‘25.7742658’; $lng = ‘-80.1936589’; $miles = 30; Query SELECT *, (

  • 0

Options

$lat = '25.7742658';
$lng = '-80.1936589';
$miles = 30;

Query

SELECT *, 
   ( 3959 * acos( cos( radians($lat) ) 
   * cos( radians( lat ) ) 
   * cos( radians( lng ) - radians($lng) ) 
   + sin( radians($lat) ) 
   * sin( radians( lat ) ) ) ) AS distance 
FROM locations 
HAVING distance < $miles 
ORDER BY distance 
LIMIT 0, 20

I have a database table with 4 columns:

  • unique id
  • city name
  • latitude (lat)
  • longitude (lng)

I’m using the query on top to return locations that are within a specified number of miles from the specified coordinates. It seems to work but I’m not sure how accurate it is. I’m curios to know whether the query is good or if you have a better solution.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T14:26:59+00:00Added an answer on May 23, 2026 at 2:26 pm

    that looks like the correct great circle distance query.

    what are you concerned with wrt accuracy?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have writen options to a <select> using something like Id.innerHTML = <option value='foo'>Foo</option>;
Trying to programmatically add options to a SELECT drop down in IE Windows Mobile.
First is the code // It's a test string NSString* aString = @,{id:\bd\,name:\ac\,latlng {lat:37.492488999999999,lng:127.014357}};
I have a Google map with 400+ polygons, these polygons consist of 40.000+ lat/lng
I'm using Google Maps API v3. My code takes objects (name, lat, lng, and
var options = { map_frame_id: mapframe, map_window_id: mapwindow, lat_id: filter_lat, lng_id: filter_lng, addr_id: filter_address,
Options +FollowSymlinks RewriteEngine On RewriteCond %{HTTP_HOST} ^http://agilerent.com$ [NC] RewriteRule ^(.*)$ http://www.agilerent.com/$1 [R=301,L] this is
What options do you have to communicate between the WARs in an EAR? We
What options do I have to work around disabled cookies for session management?
What options exist for identifying the client name of a particular client from within

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.