Posts Tagged ‘data type’

monetary data: decimal vs. double

Friday, May 22nd, 2009 by dreamluverz




The DECIMAL and NUMERIC data types are used to store exact numeric data values. In MySQL, NUMERIC is implemented as DECIMAL. These types are used to store values for which it is important to preserve exact precision, for example with monetary data.

Related article: http://dreamluverz.com/developers-tools/mysql/double-float-decimal

Data truncated for column

Wednesday, January 21st, 2009 by dreamluverz




First time I got this error Data truncated for column. I’m using mysql version 5 and I got a simple query like this:

$val1= 1;
$val2 = 3;
INSERT INTO TBL(‘val1′, ‘val2′) VALUES ($val1, $vall2);
Notice the variable name for $val2 in the query?  I fixed the variable name to $val2 and problem solved.
I really don’t know what causes this but that solves my problem.

I also notice on mysql 5 it returns an error ‘data type’ when let say I got a field that’s integer and upon saving the variable value for that is empty.