Porl123 Posted August 31, 2008 Share Posted August 31, 2008 I have a variable that contains a random number $rand = rand(0.1,0.3); and I try to update my record in my database UPDATE table SET field = field + $rand the data type in for this row is decimal, but for some reason when it goes through, the number rounds itself. I've never really used decimals much before so it's might be obvious where I'm going wrong, but I don't want it to round off. Can anyone tell me what's wrong? Much thanks Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted August 31, 2008 Share Posted August 31, 2008 This may help http://dev.mysql.com/doc/refman/5.1/en/precision-math-decimal-changes.html I believe you need to specify a precision for it and I think it is defaulted to 0 if not set so thus it rounds to 0. Quote Link to comment Share on other sites More sharing options...
Porl123 Posted August 31, 2008 Author Share Posted August 31, 2008 Ah thanks man, that's work Quote Link to comment 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.