Thanks for the correction.
Rolf
John W. Holmes wrote:
*This message was transferred with a trial version of CommuniGate(tm) Pro*
ithow can I have a field in MySQL that represents a monetary value i.e.
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