Update mySQL columns with random values between 2 given (with decimals) -
i'm trying update ratingvalue column in mysql random number between 3.8 , 5.0.
the column type in mysql set decimal (2,1) , code tried (with many changes, no success) is:
$min = 3.8; $max = 5.0; $query = "update users set ratingvalue=floor($min+(rand()*($max-$min+0.1)));"; $result = $baza->query($query);
but never updates value after decimal, rounds full value (ie. 4.0 or 5.0).
i appreciate help.
this should random number between 3.8 , 5.0 1 position.
round(floor(13 * rand()) / 10, 1) + 3.8
it first gets random number between 0 , 12 divides 10 adds 3.8.
Comments
Post a Comment