&
This page is part of MariaDB's Documentation.
The parent of this page is: SQL Operators for MariaDB Xpand
Topics on this page:
Overview
Bitwise "and".
USAGE
number1 & number2
Value Name | Description |
---|---|
| Two numbers to combine with bitwise "and" |
DETAILS
The &
operator performs a bitwise "and" of two numbers.
If you imagine each number in binary representation aligned by their least-significant bit, a bitwise "and" generates a 1
result bit for each pair of aligned bits that are 1
in both values while generating a 0
result bit for all other bit combinations.
The return value is the number representing the bits that both numbers have in common.
A NULL
is returned if either number
is NULL
.
EXAMPLES
SELECT 5 & 4, 1 & 3, 0 & 7;
+-------+-------+-------+
| 5 & 4 | 1 & 3 | 0 & 7 |
+-------+-------+-------+
| 4 | 1 | 0 |
+-------+-------+-------+