K20GH - 2 months ago 5x

MySQL Question

I've tried using DECIMAL with (2,2) but it won't let me use this.

I simply want to store a number, for example 7.50 or 10.50. I need to keep both numbers after the decimal though but when I refresh the database it resets the values to 0.99. Any suggestions?

Answer

The first digit of the `DECIMAL`

declaration is the *total* digits. You probably want to use `DECIMAL (4, 2)`

. This allows for up to two digits before the decimal and two after.

Documentation: https://dev.mysql.com/doc/refman/5.7/en/precision-math-decimal-characteristics.html

Source (Stackoverflow)

Comments