I have found many similar posts and even tried to find out how to handle negative values within MySQL, but to no avail.
I have a site that I'm using Google Maps on and as a performance enhancement I'm limiting the markers that are drawn on the map to those that are within the map boundaries.
I would like to develop a query that will work with positive or negative latitude
and longitude
values.
For the database:
latitude FLOAT( 10, 6 )
longitude FLOAT( 10, 6 )
The query:
SELECT *
FROM `table`
WHERE `latitude` BETWEEN 47.926930 AND 47.929806
AND `longitude` BETWEEN -97.077303 AND -97.083997
If I drop the BETWEEN
clause for longitude
I get results, albeit incorrect with no longitude
constraint.
I have tried this:
AND -`longitude` BETWEEN ABS( -97.077303 ) AND ABS( -97.083997 )
Which does work, but only for negative longitude
values.
Do I need to check longitude
if its negative?