top of page
CerebroSQL

MySQL: 

BIT_OR

Syntax:
BIT_OR(expr) [over_clause]

Returns the bitwise OR of all bits in expr.

The result type depends on whether the function argument values are
evaluated as binary strings or numbers:

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

o Binary-string evaluation produces a binary string of the same length
as the argument values. If argument values 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. If the
argument size exceeds 511 bytes, an
ER_INVALID_BITWISE_AGGREGATE_OPERANDS_SIZE
(https://dev.mysql.com/doc/mysql-errors/8.0/en/server-error-reference
.html#error_er_invalid_bitwise_aggregate_operands_size) error occurs.
Numeric evaluation produces an unsigned 64-bit integer.

If there are no matching rows, BIT_OR() returns a neutral value (all
bits set to 0) having the same length as the argument values.

NULL values do not affect the result unless all values are NULL. In
that case, the result is a neutral value having the same length as the
argument values.

For more information discussion about argument evaluation and result
types, see the introductory discussion in
https://dev.mysql.com/doc/refman/8.0/en/bit-functions.html.

As of MySQL 8.0.12, this function executes as a window function if
over_clause is present. over_clause is as described in
https://dev.mysql.com/doc/refman/8.0/en/window-functions-usage.html.

URL: https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html

Example

bottom of page