Solved

Decimal formats in MySQL

Posted on 2004-09-13
4
10,682 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

Introduction In this installment of my SQL tidbits, I will be looking at parsing Extensible Markup Language (XML) directly passed as string parameters to MySQL 5.1.5 or higher. These would be instances where LOAD_FILE (http://dev.mysql.com/doc/refm…
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikipedia.org/wiki/PHP  Very powerful.  But a…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
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…

776 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