BITWISE_AND()

All functions > BITWISE > BITWISE_AND()

Returns the bitwise AND of two bitstrings.

Signatures

Returns: Result bitstring, or NULL if either operand is NULL

BITWISE_AND(left: BITSTRING, right: BITSTRING) → BITSTRING
sql
ParameterTypeRequiredDescription
leftBITSTRINGYesLeft operand
rightBITSTRINGYesRight 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

Availability

Available on DuckDB. Not available on Trino, Serving.

Related operators

Examples

FeatureQL
SELECT
    -- AND preserves common 1-bits
    f1 := BITWISE_AND('10101'::BITSTRING, '10001'::BITSTRING)::VARCHAR
;
Result
f1 VARCHAR
10001