Hi, There are several ways to solve the problem - 1. Check if you really need an unsigned column - if not just alter the column to signed 2. A simple workaround for substracting unsigned values is to add a floating point number to the operation - then all values will be converted to float and the negative value will be displayed. For example this should give you what you need
select 15.0 - id from test; 3. Use CAST function. Example: select cast(15-id as signed) from test; HTH Dobromir Velev [EMAIL PROTECTED] ----- Original Message ----- From: "Octavian Rasnita" <[EMAIL PROTECTED]> To: "Stefan Hinz, iConnect (Berlin)" <[EMAIL PROTECTED]>; "Brian Lindner" <[EMAIL PROTECTED]> Cc: "MySQL" <[EMAIL PROTECTED]> Sent: Monday, January 20, 2003 08:22 Subject: Re: Substraction > But I don't want to perform a 15 - id, meaning 15 - 10. > I want to calculate 5 - id, meaning 5 - 10. > > It should give me -5 or 5 but not | 18446744073709551611 | > > > Teddy, > Teddy's Center: http://teddy.fcc.ro/ > Email: [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 1:09 AM > 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