Reputation: 1540
I have this UPDATE query:
UPDATE ws_users SET us_credits='251181.5' WHERE us_id=2;
The us_credits
field, as you can see is a floating field with a default value of zero:
Every UPDATE query trying to set a floating value to us_credits
results on an integer, for example, the query first typed results on a 251182 record on this field.
If I try to make a manual change to the record as seen above, it neither records the floating value, just integer (251184 in this case):
Upvotes: 2
Views: 2031
Reputation: 44864
MySQL permits a nonstandard syntax: FLOAT(M,D) or REAL(M,D) or DOUBLE PRECISION(M,D). Here, “(M,D)” means than values can be stored with up to M digits in total, of which D digits may be after the decimal point.For example, a column defined as FLOAT(7,4) will look like -999.9999 when displayed. MySQL performs rounding when storing values, so if you insert 999.00009 into a FLOAT(7,4) column, the approximate result is 999.0001.
https://dev.mysql.com/doc/refman/5.0/en/floating-point-types.html
So you need to define the column for handing the decimal points also.
Upvotes: 2