• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2086
  • Last Modified:

Decimal formats in MySQL

Hi all

How do i define a currency format in mySql
I have imported a Access database table to mySql

Got a collum containing prices  with 2 decimal after a comma... like this    7,25  euro
but after the import / conversion   i only get                                            7      euro  in the table  

i made a dump file where i clipped this behavior


So is it possible to define the above pice of code to containe 2 decimals after the comma

thanks in advance

rgds Jens
  • 4
  • 2
1 Solution
Define your field in MySQL as this:

DECIMAL( 3, 2 )

This will allow 3 digits to the right of the decimal and 2 to left, as such:


If you want more digits (meaning mo money), increase the 3.
Sorry - my bad.  From the MySQL manual:

salary DECIMAL(5,2)

In this example, 5 is the precision and 2 is the scale. The precision represents the number of significant decimal digits that will be stored for values, and the scale represents the number of digits that will be stored following the decimal point.

In this case, a 5 on the right means you will have 4 digits to the right of decimal, so this wil allow:


My above example, DECIMAL( 3, 2 ), would only allow this:


Hope this helps!

vbturboAuthor Commented:
Hi there

I got only 2more questions

1) ...for example  if i want to define the digits before the comma
as a wildcard/joker sign  (*,2) is that posible ?

2)  and is it also posible for the amount of digits to grow ???

I want do it  something like this....because if want to make a sale than i cant know the amout
of digits (price)  in advance

Build your data science skills into a career

Are you ready to take your data science career to the next step, or break into data science? With Springboard’s Data Science Career Track, you’ll master data science topics, have personalized career guidance, weekly calls with a data science expert, and a job guarantee.

I'm afraid you can't wildcard.  But you can declare it as large as you want, like 10, 2, to accomodate $999,999,999.99.  And If you're selling something that costs that much, you can afford to pay someone else to program it :)
Sorry, in answer to your second question: since you can't wildcard, the digits can't grow.  You have to explicitly declare them.
vbturboAuthor Commented:
Hi Again

Want to thank you for simple and easy explanation

Regards Jens
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now