Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update with float type in MySQL

I'm trying to do a simple update query in MySQL but it doesn't work:

UPDATE dimensions
SET is_active = 1
WHERE eco_tax = 19.2;

eco_tax is a FLOAT type column and it seems that here is the problem, because when I try updating with an INT column it works.

So what cand I do to use a float in column in my where syntax in MySQL?

like image 500
zuzuleinen Avatar asked Jan 18 '23 04:01

zuzuleinen


2 Answers

I always encounter issues when i want to do WHEREs in databases, and it is most likely a issue with floating point math. I know that doubles work the same way, but for some odd reason, it always works with using doubles. Therefore, my suggestion to you is to change the datatype to double instead.

like image 188
Jan Dragsbaek Avatar answered Jan 29 '23 09:01

Jan Dragsbaek


Use double instead of float. It seems there has a bug of mySql. See the following link for more information.

http://bugs.mysql.com/bug.php?id=14268

like image 33
Ariful Islam Avatar answered Jan 29 '23 10:01

Ariful Islam