I’m trying to execute this query:
SELECT `venues` . *
FROM `venues`
WHERE `lat` >= 39.847991180331
AND `lng` >= -86.332592054637
AND `lat` <= 40.137846252794
AND `lng` <= -85.954901904578
LIMIT 0 , 30
Here is the table structure of the lat and lng fields and a sample row, it should be returning AT LEAST 1 row
lng decimal(65,15)
lat decimal(65,15)
Name Lng Lat
Ambre Blends Studio -86.143746979607530 39.875314973898870
However when I execure the above query it returns no rows. What’s the problem here?
I’m always circumspect about floating point equality and inequality operations and MySQL has had a history of problems in the past with this sort of thing (I’m not sure which version you’re using but there were some changes made around 503/505).
The first thing I would do is debug the actual statement. Start with:
and ensure you only get one row (you may have to tweak the
whereclause if there’s lots of rows starting withAmbre).Then add the other subclauses one at a time until the row doesn’t appear. The first would be:
Once you establish which condition is causing the
selectto fail, you can start looking into why.