If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Substract unsigned fields

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-13-11, 19:46
bono56 bono56 is offline
Registered User
 
Join Date: May 2004
Posts: 133
Substract unsigned fields

I have table with two int unsigned field(a,b). I run statement like this:
SELECT a-b AS x
When the result became negative, it returns a big strange number. I know it has something to do with unsigned fields, but my question is how can i get the negative number without changing tables?
And another thing is i alter table, and remove unsigned property, but the result didnt change, i think i should recreate the table and insert the data again to get the right neg numbers?
Reply With Quote
  #2 (permalink)  
Old 02-13-11, 22:05
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,535
SELECT CAST(a-b AS SIGNED) AS x

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On