SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Best field type for currency (price of a product)

    Hello,

    Just wondering what you guys the best SQL field type is to store a price?

    I need to be able to display this price on a website and need to be able to order by it!

    Just wondered what you guys would do?

    Regards

    Shaun

  2. #2
    SitePoint Member Mez's Avatar
    Join Date
    Mar 2008
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Take a look at http ://dev.mysql.com/doc/refman/5.0/en/numeric-types. html

  3. #3
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,708
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Decimal. Double and Float, which I see too many people use, are subject to rounding errors.

  4. #4
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    After reading through the link Mez provided I agree that Decimal would be the best!

    But how do I display a decimal value as currency.

    For example: 27995.00 needs to be displayed as £27,995.00!

    Regards

    Shaun

  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,347
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Quote Originally Posted by sb44940 View Post
    For example: 27995.00 needs to be displayed as 27,995.00!
    do the formatting in your front end application (php or whatever)
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  6. #6
    SitePoint Enthusiast
    Join Date
    Feb 2007
    Posts
    69
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great!

    Thanks again for your help there!

    Regards

    Shaun


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •