BIT_AND
All functions > BITWISE > BIT_AND
Returns the bitwise AND of two bitstrings.
Signatures
Returns: Bitwise AND of the two operands
BIT_AND(left: BITSTRING, right: BITSTRING) → BITSTRING sql
| Parameter | Type | Required | Description |
|---|---|---|---|
left | BITSTRING | Yes | First bitstring operand |
right | BITSTRING | Yes | Second bitstring operand |
Notes
- Both operands must have the same length
- Each bit position is ANDed independently: 1 AND 1 = 1, all other combinations = 0
- Returns NULL if either input is NULL
Examples
FeatureQL
SELECT
f1 := BIT_AND('10101'::BITSTRING, '10001'::BITSTRING)::VARCHAR, -- AND preserves common 1-bits
f2 := BIT_AND('1111'::BITSTRING, '1010'::BITSTRING)::VARCHAR, -- Masking with AND
f3 := BIT_AND('1100'::BITSTRING, '0011'::BITSTRING)::VARCHAR -- No common bits
;Result
| f1 VARCHAR | f2 VARCHAR | f3 VARCHAR |
|---|---|---|
| 10001 | 1010 | 0000 |
On this page