Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Update to flip sign of a value?

Tags:

sql

sql-update

Someone entered a ton of numeric data into a table with the sign backwards.

Is there a clean way to flip the sign in the numeric column with a SQL statement?

like image 410
Eric J. Avatar asked Feb 17 '10 03:02

Eric J.


People also ask

How do you flip a value in SQL?

SQL Server REVERSE() Function The REVERSE() function reverses a string and returns the result.

How do I make a negative value positive in SQL?

As Tyson said, just multiply by -1. positive values become negative ( 1 * -1 = -1).

What does like %% mean in SQL?

The LIKE operator is used in a WHERE clause to search for a specified pattern in a column. There are two wildcards often used in conjunction with the LIKE operator: The percent sign (%) represents zero, one, or multiple characters. The underscore sign (_) represents one, single character.


1 Answers

update my_table
  set amount = -amount
  where <whatever>
like image 117
Ray Avatar answered Oct 16 '22 11:10

Ray