Jump to content

[SOLVED] selecting where field is float


abs0lut

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/129065-solved-selecting-where-field-is-float/
Share on other sites

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.