Comparison operators

    Table of contents

    For simple , the following basic operators can be used:

    When comparing strings, a lexicographical comparison is performed:

    When comparing dates, can be used:

    Tip

    Comparison operators are commonly used to filter rows (e.g., in the WHERE and clauses of a SELECT statement). However, basic comparison operators can be used as in any context. For example:

    Within a WHERE clause, the following operators can also be used:

    Operator

    Description

    Matches regular expression (case sensitive)

    !~

    Matches regular expression (case insensitive)

    !~

    Does not match regular expression (case sensitive)

    Does not match regular expression (case insensitive)

    Matches a part of the given value

    NOT

    Negates a condition

    Matches a null value

    IS NOT NULL

    Matches a non-null value

    ip << range

    True if IP is within the given IP range (using )

    x BETWEEN y AND z

    Shortcut for x >= y AND x <= z

    See also