Hi, I have the same problem the last week - I checked the manual and it seems this is from the new way the unsigned columns are treated in MySQL 4.
Here is a quote from http://www.mysql.com/doc/en/Column_types.html "Warning: you should be aware that when you use subtraction between integer values where one is of type UNSIGNED, the result will be unsigned!" A workaround for this problem which is described in the manual is either to cast the column to a signed integer or to include a double value (0.0 or something like this) in the operation. Check http://www.mysql.com/doc/en/Cast_Functions.html for more information HTH Dobromir Velev [EMAIL PROTECTED] ----- Original Message ----- From: "Stefan Hinz, iConnect (Berlin)" <[EMAIL PROTECTED]> To: "Brian Lindner" <[EMAIL PROTECTED]>; "Octavian Rasnita" <[EMAIL PROTECTED]> Cc: "MySQL" <[EMAIL PROTECTED]> Sent: Monday, January 20, 2003 01:09 Subject: Re: Substraction > Brian, > > > > create table test(id int unsigned); > > > insert into test values(10); > > > select 15 - id from test; > > > The result is 18446744073709551611 instead of -5. > > Trying to confirm this with MySQL 4.0.7 on a Win2K box: > > mysql> create table test(id int unsigned); > Query OK, 0 rows affected (0.56 sec) > > mysql> insert into test values(10); > Query OK, 1 row affected (0.08 sec) > > mysql> select 15 - id from test; > +---------+ > | 15 - id | > +---------+ > | 5 | > +---------+ > 1 row in set (0.06 sec) > > Now, once again with phpMyAdmin 2.3.3pl1: > > SELECT 15 - id > FROM test LIMIT 0, 30 > 15 - id > 5 > > But with the following statement (same with phpMyAdmin): > > mysql> select 5 - id from test; > +----------------------+ > | 5 - id | > +----------------------+ > | 18446744073709551611 | > +----------------------+ > 1 row in set (0.00 sec) > > Check the "1" in your "15". Maybe there's something wrong. > > Regards, > -- > Stefan Hinz <[EMAIL PROTECTED]> > Geschäftsführer / CEO iConnect GmbH <http://iConnect.de> > Heesestr. 6, 12169 Berlin (Germany) > Tel: +49 30 7970948-0 Fax: +49 30 7970948-3 > > ----- Original Message ----- > From: "Brian Lindner" <[EMAIL PROTECTED]> > To: "Octavian Rasnita" <[EMAIL PROTECTED]> > Cc: "MySQL" <[EMAIL PROTECTED]> > Sent: Sunday, January 19, 2003 10:28 PM > Subject: Re: Substraction > > > > Octavian, > > > > Sunday, January 19, 2003, 7:31:57 AM, you wrote: > > > Hi all, > > > > > I've tried the following query: > > > > > create table test(id int unsigned); > > > insert into test values(10); > > > select 15 - id from test; > > > > > The result is 18446744073709551611 instead of -5. > > > > I ran this.. and it worked for me > > > > MySql 4.0.7 on Linux... ran it through phpMyAdmin > > > > > Am I doing something wrong? > > > > > Thank you. > > > > > Teddy, > > > Teddy's Center: http://teddy.fcc.ro/ > > > Email: [EMAIL PROTECTED] > > > > > > > > > > --------------------------------------------------------------------- > > > Before posting, please check: > > > http://www.mysql.com/manual.php (the manual) > > > http://lists.mysql.com/ (the list archive) > > > > > To request this thread, e-mail <[EMAIL PROTECTED]> > > > To unsubscribe, e-mail > <[EMAIL PROTECTED]> > > > Trouble unsubscribing? Try: > http://lists.mysql.com/php/unsubscribe.php > > > > > > > > > > > > -- > > Brian > > Email: <[EMAIL PROTECTED]> > > > > > > > > > > --------------------------------------------------------------------- > > Before posting, please check: > > http://www.mysql.com/manual.php (the manual) > > http://lists.mysql.com/ (the list archive) > > > > To request this thread, e-mail <[EMAIL PROTECTED]> > > To unsubscribe, e-mail > <[EMAIL PROTECTED]> > > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > > > > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php