在mysql整数8.5中存储为8.0 [重复]

This question already has an answer here:

Trying to insert integer 1.5 with PHP in mysql db but numbers inserting as 1.0, 2.0 how to insert as I need correctly (1.5)?

$number = 1.5;

number mysql data type: number numeric(3,2);

$stmt = $this->db->prepare('UPDATE scores SET number = ? WHERE id = 1');
$stmt->bind_param('i', $number);

UPDATED: Problem was $stmt->bind_param('i', $number); it was updating mysql record as integer (i) (1). Correct use $stmt->bind_param('d', $number); Before updating entry decelerating in $stmt it as (d) double (1.5).

</div>

First 1 and 2 are integers 1.5 is float or double value which means that your value type in this field must match this type. Try to change its type.

Second I think that ID in table if it is a primary key cannot be then autoincremented if type is double/float so you need to be sure that every record in database table is correct.

I want you also to ask why you want push an float/double to ID its not a good choice of choosing name for number in table. Better way is to have unique identifier name ID is not one of the best because it determines something primary in mysql.

Please use number datatype FLOAT and Length 15,2. i hope solve you problem.