K20GH K20GH - 6 months ago 25
MySQL Question

How to store decimal in MySQL?

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?


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