PolarDB for Oracle supports the following comparison operators for all valid data types. All comparison operators are binary operators that return boolean values.
| Operator | Description | Example |
|---|---|---|
< | Less than | salary < 5000 |
> | Greater than | salary > 5000 |
<= | Less than or equal to | salary <= 5000 |
>= | Greater than or equal to | salary >= 5000 |
= | Equal | status = 'active' |
<> | Not equal | status <> 'inactive' |
!= | Not equal | status != 'inactive' |
Because comparison operators return boolean values, chaining them is not valid. For example, 1 < 2 < 3 is invalid — the second < would need to compare a boolean result with 3, which is not supported.
BETWEEN
The BETWEEN construct tests whether a value falls within an inclusive range:
a BETWEEN x AND yis equivalent toa >= x AND a <= ya NOT BETWEEN x AND yis equivalent toa < x OR a > y
Both forms produce identical results. The first form is internally rewritten to the second before execution.
NULL comparisons
To test whether a value is NULL, use IS NULL or IS NOT NULL:
expression IS NULL
expression IS NOT NULLDo not use expression = NULL. NULL represents an unknown value, so comparing it with = does not return true — it returns NULL. This behavior conforms to the SQL standard.
If your application relies on expression = NULL returning true, update it to use IS NULL instead.