I want to store many records in a MySQL database. All of them contains money values. But I don't know how many digits will be inserted for each one.
Which data type do I have to use for this purpose?
VARCHAR or INT (or other numeric data types)?
MySQL – Best Data Type to Store Money Values
currencymysqlsqldatatypes
Best Answer
Since money needs an exact representation don't use data types that are only approximate like
float
. You can use a fixed-point numeric data type for that like15
is the precision (total length of value including decimal places)2
is the number of digits after decimal point9999999999999.99
See MySQL Numeric Types: