Selecting a float in MySQL
Solution 1:
Casting to a decimal worked for me:
SELECT * FROM table WHERE CAST(price AS DECIMAL) = CAST(101.31 AS DECIMAL);
However, you may want to consider just making the price
column a DECIMAL in the first place. DECIMAL is generally considered to be the best type to use when dealing with monetary values.
Solution 2:
It doesn't work because a float is inherently imprecise. The actual value is probably something like '101.3100000000001' You could use ROUND() on it first to round it to 2 places, or better yet use a DECIMAL type instead of a float.