OR

All functions > LOGICAL > OR

Returns TRUE when at least one boolean operand is TRUE.

Syntax

expr1 OR expr2  ·  OR(expr1, expr2)

Function form

Returns: TRUE if at least one operand is TRUE; FALSE only when both are FALSE; otherwise NULL (three-valued logic)

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

Notes

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

Examples

expr1 OR expr2

FeatureQL
RETURN
    -- Infix one true
    f1 := FALSE OR TRUE,
    -- Infix both false
    f2 := FALSE OR FALSE,
    -- Infix TRUE absorbs NULL
    f3 := TRUE OR NULL::BOOLEAN,
    -- Infix unknown with FALSE
    f4 := FALSE OR NULL::BOOLEAN
;
Result
f1 BOOLEANf2 BOOLEANf3 BOOLEANf4 BOOLEAN
truefalsetrueNULL

OR(expr1, expr2)

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