MySQL value out of range for decimal column

After searching, I found a lot of problems out of range with people, not knowing that the first digit, m, in decimal (m, n) is the total number of digits. However, this is not my problem.

For the column in question, I have the following:

Field | Type                   | Null | Key | Default | Extra
preco | decimal(50,2) unsigned | NO   |     | 0.00    |

The decimal (50.2) parameter is more than I really want or need. I really want only 10 digits. Its price, therefore nothing more than 100 million, is probably ridiculous, so decimal (10.2) is likely to be more suitable. However, MySQL does not accept the following query:

INSERT INTO `produto` (`tipo_id`, `preco`, `qtd`, `opcao1`) VALUES (110, '77888555.43', '10', 'Azul')

I tried the query through CodeIgniter, phpMyAdmin and directly in the MySQL command line client. I also tried this without quotes for decimal value, but always get the same error:

"Out of range value for preco column in row 2"

0
source share
3 answers

I tried it with SQLyog , it works fine. I tried to change both paths in SQLyog directly through the "Table Data" tab and using the "Query". It just works. there seems to be no problem in the decimal range, but the problem is where else. See Attached Screenshots

Directly through the table data tab Directly through Table Data Tab

Through an insert request Through insert query

Table structure enter image description here

Hope this helps ...

+1
source

You send the value for precoas a string, which is accepted by MySQL in the same way as a numeric value.

+2
source

, . .

-1
source

All Articles