Table 4-1. Comparison Operators
|<=||less than or equal to|
|>=||greater than or equal to|
|<> or !=||not equal|
Note: 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.
a BETWEEN x AND yis equivalent to
a >= x AND a <= ySimilarly,
a NOT BETWEEN x AND yis equivalent to
a < x OR a > yThere 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 NULLDo 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.) Postgres presently converts x = NULL clauses to x IS NULL to allow some broken client applications (such as Microsoft Access) to work, but this may be discontinued in a future release.