Answer the question
In order to leave comments, you need to log in
Unusual MySQL behavior on UPDATE?
Good day.
There is a table with a FLOAT type column (it stores the state of a certain virtual account).
Write-off is made by the following request:
UPDATE client_data SET `client_balance` = (`client_balance` - %сумма%) WHERE `id` = %id клиента%
Answer the question
In order to leave comments, you need to log in
Read here: dev.mysql.com/doc/refman/5.0/en/problems-with-float.html
Floats store approximate values. Use decimal
I advise you to read this: dev.mysql.com/doc/refman/5.1/en/problems-with-float.html
This behavior is due to the peculiarity of storing real numbers. And this applies to almost all programming languages.
It is really better to use the DECIMAL type to store the balance.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question