-

Operator Description

- is the minus sign operator. The minus sign operator inverts the expression’s sign from a positive number to a negative number, and vice versa.

Grammar Structure

SQL
SELECT -column1, -column2, ...
FROM table_name;

Example

Text
mysql> select -2;
+----+
| -2 |
+----+
| -2 |
+----+
Text
create table t2(c1 int, c2 int);
insert into t2 values (-3, 2);
insert into t2 values (1, 2);

mysql> select -c1 from t2;
+-----+
| -c1 |
+-----+
| 3   |
| -1  |
+-----+
2 rows in set (0.00 sec)
Last updated on