Mysql decimal: word instead of round

In my MySQL database, I have a DECIMAL field (23.5), so 5 digits after the decimal point. Now, when I will request the following:

UPDATE my_table SET my_decimal_field = 123.123456789 WHERE id = 1

And then I will take this entry:

SELECT id, my_decimal_field FROM gijhars WHERE id = 1

I get this result:

+------+------------------+
| id   | my_decimal_field |
+------+------------------+
| 5733 |   123.12346      |
+------+------------------+

So, of course, MySQL rounds these values ​​if they have more than 6 digits after the decimal point. Is there any parameter in MySQL floor these values ​​instead of rounding?

+5
source share
1 answer

From doc

, , . ( , .)

, truncate

UPDATE my_table 
SET my_decimal_field = truncate(123.123456789, 5) 
WHERE id = 1

SQLFiddle

+6

All Articles