Solved

Decimal formats in MySQL

Posted on 2004-09-13
4
10,684 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
ID: 12045301
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
ID: 12045822
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
ID: 12051974
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
ID: 12053289
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
understanding output of mysql version 2 65
Amazon Redshift 2 39
PHP - AJAX and MySQL it works only if the value is a number 12 72
change database name 2 36
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…
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

856 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