1264 Out of range value adjusted for column with decimal field

Asked

Viewed 4,362 times

0

I have a hotel table in my database with a column estrelas(decimal(1,1)) which receives the hotel grade (from 0.0 to 5.0), however whenever I try to insert or change a field and put a value greater than 0.9 it does not record giving this warning:

Warning: #1264 Out of range value adjusted for column 'stars' at Row 1

and the value returns to 0,9.

Does anyone know what that could be? I already deleted the table and recreated with this sql code

CREATE TABLE IF NOT EXISTS hotel_db.Hotel (
    id INT AUTO_INCREMENT PRIMARY KEY,
    nome VARCHAR(100) NOT NULL,
    endereco VARCHAR(100) NOT NULL,
    estrelas DECIMAL(1,1);
)

but the error persists.

1 answer

1


The problem is in the data type. Try to change to decimal(3,2). According to the documentation, the first parameter is the maximum number of digits, while the second is the number on the right side of the decimal point.

  • Then @user42020 put the field as decimal(2,1) and worked.

  • As for the first number being the number of digits, I already knew, so I had put decimal (1,1) because I was going to insert values like 0.5, 2.5, 3.5 understood?

  • Oh yes, I get it. I’m glad you solved. :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.