top of page
CerebroSQL

MySQL: 

|

Syntax:
|

Bitwise OR.

The result type depends on whether the arguments are evaluated as
binary strings or numbers:

o Binary-string evaluation occurs when the arguments have a binary
string type, and at least one of them is not a hexadecimal literal,
bit literal, or NULL literal. Numeric evaluation occurs otherwise,
with argument conversion to unsigned 64-bit integers as necessary.

o Binary-string evaluation produces a binary string of the same length
as the arguments. If the arguments have unequal lengths, an
ER_INVALID_BITWISE_OPERANDS_SIZE
(https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference
.html#error_er_invalid_bitwise_operands_size) error occurs. 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 29 | 15;
-> 31
mysql> SELECT _binary X'40404040' | X'01020304';
-> 'ABCD'

bottom of page