mysql - Get nearest location in database -


I am trying to get the closest position to any user input from within the database (closest store at latitude and longitude ), So based on the postcode of users I am converting latitude and longitude, and with these results, I need to search my databases for shops that are closest to these values. I have tried to do some of the latitude and longitude of all the stores and so far (seeing past questions):

  SELECT * mystore_table from WHERE 'latitude' & gt; = (51.5263472 * 9) and `longitude` & amp; Lt; = (- 0.3830181 * 1.1) Order by stomach (latitude - 51.5263472 and longitude - -0.3830181) boundary 1;  

When I run this query, it displays a result, but it is not a nearby store, not sure it can happen with negative numbers, both my column latitude + Is longitude saved as a decimal data type?

You should try this one arithmetic instead of command :

WHERE 'latitude' & gt; from
  SELECT * mystore_table = (51.5263472 * .9) and 'Regdt` & lt; = (- 0.3830181 * 1.1) Order by stomach (latitude - 51.5263472) + ABS (longitude - -0.3830181) boundary 1;  

In your original version and will produce a boolean value, either 0 or 1 - - and it will only be 1 if the value is exactly from the last decimal point. Not very interesting.

There are several reasons why this is not the nearest distance, but it can be very close to your goals. Here are some reasons:

  • The square of the difference in the Ecliptic distance
  • The distance between the two latitudes depends on the longitude (approximately 0 0 0 on the poles).

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -