AND

All functions > LOGICAL > AND

Returns TRUE when both boolean operands are TRUE.

Syntax

expr1 AND expr2  ·  AND(expr1, expr2)

Function form

Returns: TRUE only when both operands are TRUE; FALSE when either operand is FALSE; otherwise NULL (three-valued logic)

AND(expr1: BOOLEAN, expr2: BOOLEAN) → BOOLEAN
sql
ParameterTypeRequiredDescription
expr1BOOLEANYesFirst boolean expression
expr2BOOLEANYesSecond boolean expression

Notes

  • Chains as nested binary AND: a AND b AND c groups as (a AND b) AND c
  • AND binds tighter than OR — mix them with parentheses when in doubt
  • Three-valued logic: FALSE with NULL yields FALSE; TRUE with NULL yields NULL; both NULL yields NULL

Examples

expr1 AND expr2

FeatureQL
RETURN
    -- Infix both true
    f1 := TRUE AND TRUE,
    -- Infix one false
    f2 := TRUE AND FALSE,
    -- Infix FALSE absorbs NULL
    f3 := FALSE AND NULL::BOOLEAN
;
Result
f1 BOOLEANf2 BOOLEANf3 BOOLEAN
truefalsefalse

AND(expr1, expr2)

FeatureQL
RETURN
    -- Both true
    f1 := AND(TRUE, TRUE),
    -- One false
    f2 := AND(TRUE, FALSE),
    -- FALSE absorbs NULL
    f3 := AND(FALSE, NULL::BOOLEAN),
    -- Unknown with TRUE
    f4 := AND(TRUE, NULL::BOOLEAN)
;
Result
f1 BOOLEANf2 BOOLEANf3 BOOLEANf4 BOOLEAN
truefalsefalseNULL