View Full Version : Negative value in a table
Taylor_1978
01-20-2005, 01:29 AM
Hiya,
I am trying to enter a value in a field set to INT(11), but it will not allow negative numbers. What should this field be to allow such a value?
Thanks in advance! :thumbsup:
Taylor.
dniwebdesign
01-20-2005, 02:13 AM
varchar should be able to hold the value... then when you retrieve it just do a simple math problem to verify you want it an integer.
Example PHP:
$negativevalue=$row["column"];
$value=$negativevalue*1;
//Do whatever you want with the negative $value
I believe this should do what you want.
Alternatively, you could check the variable definition. It's likely to be defined as UNSIGNED. Note that mySql automatically adds the unsigned property to any field set to ZEROFILL: zerofill is really designed for index columns (keys and foreign keys), where a negative number doesn't make any sense
Putting numberical values in a char field is both wasteful and inefficient.
If all else fails, you might want to take a look through the manual (http://dev.mysql.com/doc/mysql/en/Numeric_types.html).
vBulletin® v3.8.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.