# **&**

## **Operator Description**

`Bitwise AND` operator, performs an AND (AND) operation for each pair of bits. Only when a and b are both 1, a AND b is 1. `Bitwise AND` Returns an unsigned 64-bit integer.

The result type depends on whether the parameter is a binary string or a number:

- When the parameters are of binary string type, and at least one of them is not hexadecimal `literal`, bit `literal` or `NULL literal`, binary string evaluation is performed; otherwise, numerical evaluation is performed and the parameters are converted to unsigned 64-bit integers as needed.

- Binary string evaluation produces a binary string with the same length as the parameter. If the lengths of the parameters are not equal, an `ER_INVALID_BITWISE_OPERANDS_SIZE` error occurs. Numerical calculations produce an unsigned 64-bit integer.

## **Grammar Structure**

```sql
SELECT value1 & value2;
```

## **Example**

```text
mysql> SELECT 29 & 15;
+-----------+
| 29 & 15 |
+-----------+
| 13 |
+-----------+
1 row in set (0.06 sec)

CREATE TABLE bitwise (a_int_value INT NOT NULL,b_int_value INT NOT NULL);
INSERT bitwise VALUES (170, 75);

mysql> SELECT a_int_value & b_int_value FROM bitwise;
+--------------------------------+
| a_int_value & b_int_value |
+--------------------------------+
| 10 |
+--------------------------------+
1 row in set (0.02 sec)
```
