How to store decimal in MySQL?

前端 未结 6 908
谎友^
谎友^ 2020-12-05 06:35

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 th

6条回答
  •  抹茶落季
    2020-12-05 07:15

    CREATE TABLE IF NOT EXISTS `table_name` (`id` int(11) NOT NULL AUTO_INCREMENT,`cost` DECIMAL( 10, 2 ) NOT NULL);
    

    This will make the cost column hold a total of 10 digits, 8 before and 2 after the decimal point.

提交回复
热议问题