Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.