What MySQL type is most suitable for "price" column?

You should certainly use a decimal type for money. Never floating point, contrary to other answers. And using varchar prevents you doing calculations.


Field type "Decimal" will work best. Like:

`product_price` decimal(8, 2) NOT NULL,

It will store a price up to 999999.99

If you have high prices then you can use

`product_price` decimal(12, 2) NOT NULL,

i.e. up to 9999999999.99


DECIMAL beacuse decimal value is stored precisely. E.g. DECIMAL(10, 2) will suit perfectly for prices not higher than 99999999,99. MySQL Docs reference

Tags:

Mysql