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
ParameterTypeRequiredDescription
leftBITSTRINGYesFirst bitstring operand
rightBITSTRINGYesSecond 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 VARCHARf2 VARCHARf3 VARCHAR
1000110100000

Last update at: 2026/03/03 16:47:38
Last updated: 2026-03-03 16:48:19