AND
PG 7.4+→ booleanLogical AND. Returns true if both operands are true. Returns NULL if either operand is NULL and the other is not false.
Signature
boolean AND boolean → booleanParameters
| Parameter | Type | Description |
|---|---|---|
| condition1 | boolean | Left operand |
| condition2 | boolean | Right operand |
Examples
SELECT true AND true;trueSELECT true AND false;falseNULL AND TRUE = NULL, not false — three-valued logic
SELECT true AND NULL;NULLfalse AND anything = false, even NULL
SELECT false AND NULL;falseSELECT * FROM orders WHERE status = 'active' AND total > 500;Rows where both conditions hold; put indexed column first for efficiencySELECT count(*) FROM events WHERE is_public AND starts_at > now();Count of upcoming public events — boolean column used directly as conditionPostgreSQL uses three-valued logic (true/false/NULL). `false AND NULL = false` (short-circuit), but `true AND NULL = NULL`. Place the cheapest/most-selective condition first for query optimization.
SELECT * FROM orders WHERE is_paid = true AND amount > 1000 AND customer_id IN (SELECT ...);Put indexed conditions first for best performance