Solved

Decimal formats in MySQL

Posted on 2004-09-13
4
10,671 Views
Last Modified: 2012-06-21
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

`Pris` DECIMAL DEFAULT 0,

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

thanks in advance

rgds Jens
0
Comment
Question by:vbturbo
  • 2
4 Comments
 
LVL 15

Expert Comment

by:VincentPuglia
Comment Utility
Hi,

  Don't know why you have commas instead of decimals, but I would convert the comma to a decimal '.' and then import it as a decimal.  You can display the values with a comma later on as needed, but you should maintain it as decimals

Vinny
0
 
LVL 18

Author Comment

by:vbturbo
Comment Utility
Hi there

Got your point.....but was my mistake "sould have been a dot  7.25 " european display format

But my question was if i got a collum containing different price's and  how do i format the
decimals

 example        Price
             ------------------
                     100.75
                 75000.50

Hope you understand my question

jens
0
 
LVL 26

Accepted Solution

by:
ushastry earned 100 total points
Comment Utility
Hi,



Some data types do not have a direct correlation between SQL Server or Access and MySQL. One example would be the CURRENCY data type: MySQL does not (yet) have a CURRENCY data type, but creating a column with the definition DECIMAL(19,4) serves the same purpose. While MSSQL defaults to Unicode character types such as nCHAR and nVARCHAR, MySQL does not so tightly bind character sets to field types, instead allowing for one set of character types which can be bound to any number of character sets, including Unicode.

take a look at

http://dev.mysql.com/tech-resources/articles/migrating-from-microsoft.html

0
 
LVL 15

Expert Comment

by:VincentPuglia
Comment Utility
Hi,

  When you say 'format the decimals' , exactly what are you talking about?
  For the database column?  ushastry's answer will do.  
  For display?  That would depend on the language you are using, not the dbms

Vinny
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

More Fun with XML and MySQL – Parsing Delimited String with a Single SQL Statement Are you ready for another of my SQL tidbits?  Hopefully so, as in this adventure, I will be covering a topic that comes up a lot which is parsing a comma (or other…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now