user188962
user188962

Reputation:

What's the decimal separator in a MySql INT field?

Is this set somehow in a variable?

Is it possible to store decimal values in INT fields or does it have to be FLOAT?

Comma or point as a separator? Or does it even matter?

Thanks

Upvotes: 3

Views: 981

Answers (3)

Tim Michalski
Tim Michalski

Reputation: 357

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

An INT field doesn't store precision. If you want to store fractions/decimals, then you need to choose a data type that will support them. The MySQL documentation is pretty good about what each data type provides you. I frequently go back to the MySQL documentation when I need a refresher on data types.

Upvotes: 1

Nick Craver
Nick Craver

Reputation: 630559

Commas aren't stored in the table...they're represented that way in whatever you're viewing the data with.

For decimal numbers, no you cannot use INT, it only accepts whole numbers, you likely want DECIMAL for this (So you don't get the odd 0.3999999999999999999999999999999 that can't be stored quite right in the float).

Upvotes: 1

Yada
Yada

Reputation: 31225

The separator is not stored in the database. You can apply separator using the FORMAT function.

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'

Upvotes: 1

Related Questions