What is the decimal separator in the MySql INT field?

Is it set somehow in the variable?

Is it possible to store decimal values ​​in fields INTor should it be FLOAT?

A comma or period as a separator? Or does it even matter?

thank

+3
source share
3 answers

The wrists are not stored in the table ... they are presented in this way in everything that you view with data.

There is no decimal numbers, you cannot use INT, it only accepts integers, you probably want DECIMALto do this (so you are not getting the odd 0.399999999999999999999999999999999 that cannot be stored perfectly correctly in the float).

+1

. , FORMAT.

mysql> SELECT FORMAT(12332.123456, 4);
        -> '12,332.1235'
mysql> SELECT FORMAT(12332.1,4);
        -> '12,332.1000'
mysql> SELECT FORMAT(12332.2,0);
        -> '12,332'
+1

http://dev.mysql.com/doc/refman/5.0/en/numeric-types.html

The INT field does not preserve accuracy. If you want to keep fractional numbers / decimals, you need to choose the data type that will support them. The MySQL documentation is pretty good at what each data type provides you with. I often return to MySQL documentation when I need to update data types.

+1
source

Source: https://habr.com/ru/post/1733029/


All Articles