Comparison operators

These operations test whether two expressions are equal. Comparison Operators result in a value of true, false or null. The following tables show the usual comparison operators that can be used for all simple data types:

Operator Description
< less than
> greater than
<= less than or equal to
>= greater than or equal to
= equal
<> not equal
!= not equal - same as <>

In addition, when the left operand is an IP and the right is text that follows CIDR notation [ip address/prefix_length], the << operator can be used as in:

'' << ''

returning true when the IP is included in the range described by the CIDR.

If used in the WHERE clause the following operators are valid in addition.

Operator Description
LIKE (ILIKE) matches a part of the given value
NOT negates a condition
IS NULL matches a NULL value
IS NOT NULL matches a Non-NULL value
~ regular expression match
!~ negated regular expression match
<< IP is included in CIDR
between a BETWEEN x and y: shortcut for a >= x AND a <= y


How helpful was this page?