0

Possible Duplicate:
storing money amounts in mysql

I am trying to create a table in my sql db that has several different int columns a name and some other stuff.. but there are two table in which I want to sotre money values in. no more than 3 digit with two decimal places when displaying it.

this is the sql I have written

CREATE TABLE `5050goose` (
    `goose_id` int(11) unsigned NOT NULL auto_increment,
    `name` varchar(100) NOT NULL default '',  
    `width` int(8),
    `height` int(8),
    `normal_fill` int(8),
    `our_fill` int(8),
    `old_price` smallmoney(8),
    `price` smallmoney(8),
    PRIMARY KEY  (`goose_id`)
    ) TYPE=MyISAM;

however when I execute this I am getting this error

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'smallmoney(8),
    `price` smallmoney(8),
    PRIMARY KEY  (`goosedown_id`)
    ) TYPE' at line 8 

which clearly says smallmoney is not working for me.. So I would like to know how to store a monetary value in my sql db.

Cœur
  • 37,241
  • 25
  • 195
  • 267
HurkNburkS
  • 5,492
  • 19
  • 100
  • 183

1 Answers1

1

Indeed you are correct, smallmoney is not a data type in mysql. Have a look at DECIMAL

http://dev.mysql.com/doc/refman/5.6/en/fixed-point-types.html

Adrian Cornish
  • 23,227
  • 13
  • 61
  • 77
  • cool, have gone with DECIMAL(6,2). which should cover apparently any number between -999.99 and + 999,99 cheers for the link – HurkNburkS Sep 30 '12 at 02:57