Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

chaning a positive to negative

Status
Not open for further replies.

Neozero

MIS
Jul 7, 2000
49
US
What is the best way to update a field to change it to a negative number from a positive? Would I use insert or update?


EXAMPLE: I want to change 85996 to show as -85996.



 
Code:
UPDATE mytable
SET myfield = 0 - myfield
WHERE myfield > 0

--James
 
or

UPDATE mytable
SET myfield = -1 * myfield

if you just want the opposite wether it's positive or negative

-Rick
 
Why don't you use a simple

SET myfield = -myfield

there's no need for "-1 * myfield" or "0 - myfield" ;-)

Dieter
 
SET myfield = -myfield

which opperation does this perform though? -1*x or 0-x?

-Rick
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top