Reputation: 48500
I am using MySQL 5.6.10. My schema looks like the following:
Create Table: CREATE TABLE `nba_average_stats` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`ppg` decimal(2,1) DEFAULT '0.0',
`apg` decimal(2,1) DEFAULT '0.0',
`rpg` decimal(2,1) DEFAULT '0.0',
`tpm` decimal(2,1) DEFAULT '0.0',
`blk` decimal(2,1) DEFAULT '0.0',
`stl` decimal(2,1) DEFAULT '0.0',
`year` int(11) DEFAULT '0',
`player_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
Here's my query:
UPDATE `nba_average_stats` SET `ppg` = 18.6, `apg` = 2.6, `rpg` = 8.4, `tpm` = 0.1, `blk` = 1.5, `stl` = 0.9 WHERE `nba_average_stats`.`id` = 1
And the error:
Mysql2::Error: Out of range value for column 'ppg' at row 1:
Did I not create the ppg
column correctly? Is my precision and/or scale wrong?
Upvotes: 3
Views: 749
Reputation: 8840
DECIMAL(M,D)
M is the maximum number of digits
D is the number of digits to the right of the decimal point
Change your column size to (3,1)
Upvotes: 1