The type of float for MySQL is strange, 2 values are not equal
The table has a lot of data, but a few are strange, the field is float type, 2 values are the same
Payment value =299.7
Feiyong value =299.7
Query statement: feiyong>0 and Payment>0 and Payment
At this point can still query out, and just a few have this problem, the others are normal
------to solve the idea----------------------
Floating-point numbers represent a large number, missing part of the precision
So apply when comparing: a strategy that is equal when the absolute value of the difference of two numbers is less than a certain minimum number
Or use round to obtain a valid number after comparing
If your application needs to have a precise number of decimal digits (such as finance) then you should use the DECIMAL type
------to solve the idea----------------------
This is still quite normal. After all, float data has no way of guaranteeing the accuracy of the data.
------to solve the idea----------------------
Suggested modification type is decimal
------to solve the idea----------------------
Select ..., (Payment-feiyong) as a
Form ...
...
where Feiyong>0 and payment>0
Having a > 1e-5