abs0lut Posted October 19, 2008 Share Posted October 19, 2008 I have a big table with many float fields. I can see the fields in the tables filled with information, but when i query the table i get empty sets but not for all values. example: i can see in the table(using query browser) that there are values 1.25 in a field called fldName, when i query select * from table where fldName=1.25 i get an empty result set. with integer i get the correct results sets. Could you please help me? Quote Link to comment https://forums.phpfreaks.com/topic/129065-solved-selecting-where-field-is-float/ Share on other sites More sharing options...
Barand Posted October 19, 2008 Share Posted October 19, 2008 The trouble with floats is that 1.25 may actually be 1.250000000001 or 1.249999999999 either use DECIMAL type fields or search the floats allowing for the rounding errors. eg ... WHERE ABS(fldname - 1.25) < 0.00001 or ... WHERE fldname BETWEEN 1.249999 AND 1.250001 Quote Link to comment https://forums.phpfreaks.com/topic/129065-solved-selecting-where-field-is-float/#findComment-669158 Share on other sites More sharing options...
abs0lut Posted October 19, 2008 Author Share Posted October 19, 2008 thank you Quote Link to comment https://forums.phpfreaks.com/topic/129065-solved-selecting-where-field-is-float/#findComment-669236 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.