Using Comparison Operators in Expressions
Go Up to Understanding SQL Expressions
Comparison operators evaluate to a Boolean value: TRUE
, FALSE
, or UNKNOWN
, based on a test for a specific relationship between a value to the left of the operator, and a value or range of values to the right of the operator. Values compared must evaluate to the same data type, unless the CAST()
function is used to translate one data type to a different one for comparison. Values can be columns, constants, or calculated values.
The following table lists operators that can be used in statements, describes how they are used, and provides samples of their use:
Operator | Purpose |
---|---|
= |
Equals |
< |
Less than |
> |
Greater than |
>= |
Greater than or equals |
<= |
Less than or equals |
>, ~>, ^> |
Not greater than |
<, ~<, ^< |
Not less than |
<>, != |
Not equal to |
Comparisons evaluate to
UNKNOWN
if a NULL
value is encountered.For more information about CAST()
, see Using CAST( ) for Data Type Conversions.
InterBase also supports comparison operators that compare a value on the left of the operator to the results of a subquery to the right of the operator. The following table lists these operators, and describes how they are used:
Operator | Purpose |
---|---|
|
Determines if a value is equal to all values returned by a subquery. |
|
Determines if a value is equal to any values returned by a subquery. |
|
Determines if a value exists in at least one value returned by a subquery. |
|
Determines if a value exists in exactly one value returned by a subquery. |
For more information about using subqueries, see Using Subqueries.
Topics
- Using BETWEEN
- Using CONTAINING
- Using IN
- Using LIKE
- Using IS NULL
- Using STARTING WITH
- Using ALL
- Using ANY and SOME
- Using EXISTS
- Using SINGULAR