![](https://static.wixstatic.com/media/11062b_fac51a38acf24ea2aa030216e01a0ea3f000.jpg/v1/fill/w_288,h_162,al_c,q_80,usm_0.66_1.00_0.01,blur_2,enc_auto/11062b_fac51a38acf24ea2aa030216e01a0ea3f000.jpg)
Syntax:
~
Invert all bits.
The result type depends on whether the bit argument is evaluated as a
binary string or number:
o Binary-string evaluation occurs when the bit argument has a binary
string type, and is not a hexadecimal literal, bit literal, or NULL
literal. Numeric evaluation occurs otherwise, with argument
conversion to an unsigned 64-bit integer as necessary.
o Binary-string evaluation produces a binary string of the same length
as the bit argument. Numeric evaluation produces an unsigned 64-bit
integer.
For more information, see the introductory discussion in this section.
URL: https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html
Example
mysql> SELECT 5 & ~1;
-> 4
mysql> SELECT HEX(~X'0000FFFF1111EEEE');
-> 'FFFF0000EEEE1111'