Decimal formats in MySQL

Posted on 2004-09-13
Last Modified: 2008-03-10
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
Question by:vbturbo
  • 4
  • 2

Expert Comment

ID: 12045040
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.

Accepted Solution

itcnbwise earned 100 total points
ID: 12045081
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!

LVL 18

Author Comment

ID: 12045249
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.


Expert Comment

ID: 12045876
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 :)

Expert Comment

ID: 12045885
Sorry, in answer to your second question: since you can't wildcard, the digits can't grow.  You have to explicitly declare them.
LVL 18

Author Comment

ID: 12047993
Hi Again

Want to thank you for simple and easy explanation

Regards Jens

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Can i Import Access Table Into Oracle Using Toad 36 174
Exchange 2016 Databse move 5 56
Error Creating Foreign Keys in SQL Database 7 35
SQL Server memory sizing - reallocation 16 70
I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
Shadow IT is coming out of the shadows as more businesses are choosing cloud-based applications. It is now a multi-cloud world for most organizations. Simultaneously, most businesses have yet to consolidate with one cloud provider or define an offic…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question