Jump to content

update queries.


sepoto

Recommended Posts

I have developed the following queries but they do not operate. I get no errors from PHP or if I run them in MySQL WorkBench or PHPmyadmin. The queries do nothing at all which is the problem. The queries are supposed to set mz to 1 for the correct records. It is not working and I do not know why. I also verified that there are records that exist with lng and lat specified and import date specified. They are there for certain.

UPDATE planning SET mz='1' WHERE import_date='5/10/2011 12:00:00 AM' AND lng='-118.291' AND lat='34.0618' LIMIT 1'UPDATE planning SET mz='1' WHERE import_date='5/10/2011 12:00:00 AM' AND lng='-118.351' AND lat='34.0622' LIMIT 1'UPDATE planning SET mz='1' WHERE import_date='5/10/2011 12:00:00 AM' AND lng='-118.344' AND lat='34.0871' LIMIT 1'UPDATE planning SET mz='1' WHERE import_date='5/10/2011 12:00:00 AM' AND lng='-118.331' AND lat='34.0402' LIMIT 1'UPDATE planning SET mz='1' WHERE import_date='5/10/2011 12:00:00 AM' AND lng='-118.286' AND lat='34.0235' LIMIT 1'UPDATE planning SET mz='1' WHERE import_date='5/10/2011 12:00:00 AM' AND lng='-118.278' AND lat='34.0453' LIMIT 1'UPDATE planning SET mz='1' WHERE import_date='5/10/2011 12:00:00 AM' AND lng='-118.46' AND lat='33.9709' LIMIT 1'UPDATE planning SET mz='1' WHERE import_date='5/10/2011 12:00:00 AM' AND lng='-118.469' AND lat='33.9821' LIMIT 1'UPDATE planning SET mz='1' WHERE import_date='5/10/2011 12:00:00 AM' AND lng='-118.439' AND lat='33.9861' LIMIT 1'UPDATE planning SET mz='1' WHERE import_date='5/10/2011 12:00:00 AM' AND lng='-118.474' AND lat='33.9959' LIMIT 1'UPDATE planning SET mz='1' WHERE import_date='5/10/2011 12:00:00 AM' AND lng='-118.473' AND lat='33.9921' LIMIT 1'UPDATE planning SET mz='1' WHERE import_date='5/10/2011 12:00:00 AM' AND lng='-118.467' AND lat='33.9911' LIMIT 1'

Link to comment
Share on other sites

UPDATE planning SET mz=1 WHERE import_date='5/4/2011 12:00:00 AM' AND lng LIKE -118.413 AND lat LIKE 34.0593UPDATE planning SET mz=1 WHERE import_date='5/4/2011 12:00:00 AM' AND lng LIKE -118.285 AND lat LIKE 34.0215UPDATE planning SET mz=1 WHERE import_date='5/4/2011 12:00:00 AM' AND lng LIKE -118.316 AND lat LIKE 34.0482UPDATE planning SET mz=1 WHERE import_date='5/4/2011 12:00:00 AM' AND lng LIKE -118.469 AND lat LIKE 33.9948

I managed to get it working but there is one thing I do not understand. To begin with lng and lat are floats. I am forced to use LIKE for some reason instead of "=". If I use "=" in place of LIKE nothing updates. If I look at the values of lat & lng they are exactly as the query appears. No extra numbers or numbers left out. This does not make sense at all.

Link to comment
Share on other sites

Floats are not stored the way you probably think they are. (For example, 4.5 might be represented as something like 4.499999999; check the warning here.) If you need an EXACT representation of a float to a limited number of decimals, it might be better to store it as a string type. OTOH, if there is no chance that this level of imprecision will create collisions, using LIKE might be good enough

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...