Skip to main content
Version: V1.0.0

NEG

Declaration

NEG(expr)

Description

The NEG function performs a negation operation on the operand, which is equivalent to subtracting the operand from zero. The result is returned as the negated value of the operand.

It supports comparison operations, returning a BOOL value that is then converted to a numeric type. The result is either 1 (TRUE) or 0 (FALSE), and the negation of this result is returned.

Example

SELECT NEG(1), NEG(1+1), NEG(2*3), NEG(1=1), NEG(5<1);
+--------+----------+----------+----------+----------+
| NEG(1) | NEG(1+1) | NEG(2*3) | NEG(1=1) | NEG(5<1) |
+--------+----------+----------+----------+----------+
| -1 | -2 | -6 | -1 | 0 |
+--------+----------+----------+----------+----------+
1 row in set (0.001 sec)