I have a 4.3 float value in a table.
When sending that request :
SELECT * FROM mytable WHERE floatfield = 4.3
is return an empty result.
Even when trying ;
SELECT * FROM mytable WHERE floatfield = '4.3'
What is the problem ?
I have a 4.3 float value in a table.
When sending that request :
SELECT * FROM mytable WHERE floatfield = 4.3
is return an empty result.
Even when trying ;
SELECT * FROM mytable WHERE floatfield = '4.3'
What is the problem ?
Floating-point does not have infinite precision, and 4.3
cannot be represented exactly in a finite number of binary digits.
Use Column LIKE float instead of Column = float. Don't get the terminology behind this, it probably just matching up from the starting of the value or cut out the unseen precision digit and treat it like varchar.
You can use the following function:
DELIMITER $$
DROP FUNCTION IF EXISTS `x_cast_to_float`$$
CREATE FUNCTION `x_cast_to_float`(number FLOAT) RETURNS FLOAT
NO SQL
BEGIN
RETURN number;
END$$
DELIMITER ;
SELECT * FROM mytable WHERE floatfield = x_cast_to_float(4.3)<br />