Table 3-1. Comparison Operators
Operator | Description |
---|
< | less than |
> | greater than |
<= | less than or equal to |
>= | greater than or equal to |
= | equal |
<> or != | not equal |
| The != operator is converted to
<> in the parser stage. It is not
possible to implement != and
<> operators that do different things.
|
Comparison operators are available for all data types where this
makes sense. All comparison operators are binary operators that
return values of type boolean; expressions like
1 < 2 < 3 are not valid (because there is
no < operator to compare a Boolean value with
3).
In addition to the comparison operators, the special
BETWEEN construct is available.
is equivalent to
Similarly,
is equivalent to
There is no difference between the two respective forms apart from
the
CPU cycles required to rewrite the first one
into the second one internally.
To check whether a value is or is not NULL, use the constructs
expression IS NULL
expression IS NOT NULL |
Do
not use
expression = NULL
because NULL is not
"equal to" NULL. (NULL represents
an unknown value, so it is not known whether two unknown values are
equal.)
PostgreSQL presently converts
x = NULL clauses to
x IS NULL to
allow some client applications (such as
Microsoft Access) to work, but this may
be discontinued in a future release.