Tag: querying by distance

Querying by Distance in MySQL - Header

Querying by Distance in MySQL

Is your website doing everything possible to help your clients find you and get to you? One valuable tool that you can use to accomplish this important goal is to include a “Locations” page on your site. Suppose that your business is a chain of restaurants. In that case, a Locations page can tell customers which of your eateries is closest to the hungry person’s present location.  If you don’t yet have such a page, it’s definitely something worth considering, and here’s how programmers go about building it.

Typically, such a page consists of a search field that allows their users to provide a location, and then returns a list of nearby destinations sorted by distance, often accompanied by a Google Map.

Your only asset is a database table containing all possible locations with columns specifying latitude and longitude. When the user submits their location, you’ll likely utilize the Google Maps API to retrieve the coordinates from an address, which you can then use to compare against your database records. Continue reading