> SELECT *, ( 6371 * acos( cos( radians(-37) ) * cos( radians( -37.7833 ) ) * 
> cos( radians( 144.9833 ) - radians(144) ) + sin( radians(-37) ) * sin( 
> radians( -37.7833 ) ) ) ) AS distance FROM Geocode_AU HAVING distance < 5 
> ORDER BY distance

It's wrong, you have all fixed numbers in your formula. Whatever the
value of data in your table the formula will always evaluate to
exactly the same value. If that is more than 5, no rows will ever be
selected.

As you want to SELECT some of your rows that fit your criteria (by
radius) and discard other of your rows that don't fit your criteria,
you need the formula to include or compare data from the rows it is
examining.

The example is
SELECT id, ( 3959 * acos( cos( radians(37) ) * cos( radians( lat ) ) *
cos( radians( lng ) ... etc

where 37 is the "target" longitude for the centre of the search
and 'lat' will substitute the value from the row of data to be tested,
from each row in turn.
etc

>  Also why I don't understand is why they rounded some of the lattitudes and
> longitudes???  For example, they use -37 instead of the full -37.7833 and 144 
> instead of

As it says, "Here's the SQL statement that will find the closest 20
locations that are within a radius of 25 miles to the 37, -122
coordinate"   They're not presenting an example SELECT within a radius
of -37.7833,  etc.

> Seems odd that Google would post an example that doesn't work!???

You could take it as a clue that your implementation, which isn't the
same as Google's example, could be wrong?

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps API V2" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-api?hl=en.

Reply via email to