Skip to content

~

Operator Description

Unary operator, inverse binary. Perform a non-NOT operation on each bit. NOT a result is an inversion of a (i.e., inverse code), and the parameters can only be numeric or NULL.

Grammar Structure

> SELECT ~value1;

Example

mysql> select ~-5;
+---------+
| ~ (-5) |
+---------+
| 4 |
+---------+
1 row in set (0.00 sec)

mysql> select ~null;
+--------+
| ~null |
+--------+
| NULL |
+--------+
1 row in set (0.00 sec)

mysql> select ~a, ~b from t1;
+---------------------------------------+
| ~a | ~b |
+---------------------------------------+
| 0 | 18446744073709551614 |
| 4 | 18446744073709551610 |
+---------------------------------------+
2 rows in set (0.00 sec)