I hadn't thought of that, John. Very insightful, as per usual, list-appropriateness included. Edward Dudlik Becoming Digital www.becomingdigital.com ----- Original Message ----- From: "John W. Holmes" <holmes072000@charter.net> To: "'Rolf Brusletto'" <rolf-list@triculture.com>; "'shaun'" <shaun@mania.plus.com> Cc: <php-db@lists.php.net> Sent: Friday, 23 May, 2003 12:15 Subject: RE: Monetary field in MySQL > >how can I have a field in MySQL that represents a monetary value i.e. it > >always has 2 zeros after the decimal point? > > you can use a float type. > > ALTER TABLE `blah` ADD `aMoneyField` FLOAT(6,2) DEFAULT "0.00" You should use a DECIMAL column as you won't run into floating point error problems. Even though you say FLOAT(6,2), that's just precision. $12.25 may be stored in the database as 12.250000001 and meet the precision you gave. However, now if you're looking for a price == $12.25, this row will not be returned. DECIMAL columns are actually stored as strings, so there is no floating point errors. $12.25 is stored as "12.25" and there are no problems. Oh, and the obvious, this is not a PHP question!! ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/ -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php