Help with Lat long

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
fraser5002
Forum Newbie
Posts: 1
Joined: Tue Apr 06, 2010 12:58 pm

Help with Lat long

Post by fraser5002 »

Hi, i have a database that has a lat long for each entry .

I have a query that supplies the lat longs of all entires within a lat long window what i want to do is calculate the distance between each set of lat longs and a base lat long ( i can do the calculation fine) i need to then sort all my entries based on this calculated distance how would i go about this?
JakeJ
Forum Regular
Posts: 675
Joined: Thu Dec 10, 2009 6:27 pm

Re: Help with Lat long

Post by JakeJ »

So you want to build a distance matrix?

Go look up examples of how to build a multiplication table, there are plenty. It should serve as a base for what you're doing.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Help with Lat long

Post by pickle »

Code: Select all

SELECT
    [ FANCY CALCULATION HERE ] as `distance`
...
ORDER BY
  `distance`
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
Post Reply