Predicates
The standard comparators are available:
expr1 < expr2(less than)expr1 <= expr2(less than or equal to)expr1 > expr2(greater than)expr1 >= expr2(greater than or equal to)expr1 = expr2(equal to)expr1 <> expr2|expr1 != expr2(not equal to)
Row comparisons (v2.2.2+)
Section titled “Row comparisons (v2.2.2+)”The comparators also compare row values, written (expr, ...) or ROW(expr, ...), column by column:
(a, b) = (x, y)- equivalent to
a = x AND b = y (a, b) <> (x, y)- equivalent to
a <> x OR b <> y (a, b) < (x, y)- equivalent to
a < x OR (a = x AND b < y)- rows are ordered lexicographically, by their first column, then by their second where the first are equal, and so on (a, b) <= (x, y)- equivalent to
a < x OR (a = x AND b <= y)
> and >= follow the same pattern as < and <=.
Both rows must have the same number of columns.
A NULL column follows the usual three-valued logic: (1, NULL) = (1, 2) is null, but (1, NULL) = (2, 3) is false, because its first columns already differ.
Likewise, (1, NULL) < (2, 0) is true, but (1, 2) < (1, NULL) is null.
Greatest / Least
Section titled “Greatest / Least”These aren’t strictly predicates - they return the greatest/least value of their arguments respectively:
GREATEST(expr, ...)- returns the greatest value of the provided arguments, by the usual comparison operators
LEAST(expr, ...)- returns the least value of the provided arguments, by the usual comparison operators
Boolean functions
Section titled “Boolean functions”expr1 AND expr2- returns true if both
expr1andexpr2are true, false otherwise expr1 OR expr2- returns true if either
expr1orexpr2are true, false otherwise NOT expr- returns true if
expris false, false otherwise expr IS [NOT] TRUE- returns true if
expris [not] true, false otherwise (including ifexpris null) expr IS [NOT] FALSE- returns true if
expris [not] false, false otherwise (including ifexpris null) expr IS [NOT] NULL- returns true if
expris [not] null, false otherwise expr1 IS [NOT] DISTINCT FROM expr2- NULL-safe comparison. Returns true if
expr1andexpr2are [not] distinct - two NULLs are considered not distinct from each other, unlike standard equality.