Seems to me like it would be simpler to do two select statements, storing 
the lat and long of each site, then use a PHP function and built in PHP 
math operators to do the calculations.  Note, your forumula assumes that a 
traveller would travel a Great Circle route to get from point A to B.

>I'm trying to convert a primarily php script which does a zip code lookup
>into a mostly mysql one.  I've got alot of the math done, but don't know
>how to pull some of the data from my tables.  Here's the scenario, I have
>to get the number of miles between 2 zip codes, which are stored in 2
>different tables.  I am stuck on the part of getting 2 columns(Longitude &
>Latitude) from one table and making them available to the query (so math
>can be performed on them).  I know this can be done, but I can't seem to
>figure it out.
>
>This is what I'd like to do:
>
>select sum(
>         acos(sin(lu_zip.Latitude * 0.0174) *
>         sin(dealer_LATITUDE * 0.0174)) *
>         cos(lu_zip.Latitude * 0.0174) *
>         cos(dealer_LATITUDE * 0.0174) *
>         cos(dealer_LONGITUDE - lu_zip.Longitude) * 6371.2
>           ) AS ZipDist
>FROM lu_zip,dealerlocations WHERE(dealerlocations.AddrZip = '90210');
>
>I need the dealer latitude & longitude of the dealer zipcode (passed in
>via php) which is looked up in the lu_zip table (which contains the
>lat/long). I think I need to use JOIN, but the syntax isn't very clear.
>
>Any help would be greatly appreciated.
>
>--
>------------------------------------------------------------------------
>Jeremy Friedman
>[EMAIL PROTECTED]
>------------------------------------------------------------------------
>
>
>---------------------------------------------------------------------
>Before posting, please check:
>    http://www.mysql.com/manual.php   (the manual)
>    http://lists.mysql.com/           (the list archive)
>
>To request this thread, e-mail <[EMAIL PROTECTED]>
>To unsubscribe, e-mail <[EMAIL PROTECTED]>
>Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php


Christopher R. Jones, P.Eng.
14 Oneida Avenue
Toronto, Ontario M5J 2E3
Tel. 416 203-7465
Fax. 416 203-8249
Email [EMAIL PROTECTED]



---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to