The bit_and() function

The bit_and() function performs a bitwise logical AND operation on two binary data type columns.

Syntax

bit_and(column1, column2)
column1, column2
Two input binary data type columns.

Usage

If the columns are different lengths, the return value is the same length as the longer input parameter with the logical AND operation performed up to the length of the shorter parameter.

Return codes

The function returns the value of the bitwise logical AND operation.

If either parameter is NULL, the return value is also NULL.

Example

In the following example, the value of binaryvar_col1 is '00086000'.
SELECT bit_and(binaryvar_col1, '0003C000'::binaryvar) FROM table WHERE x = 1
expression
------------------
00004000