Relational Operators

Relational operators separating any two expressions can be any one of those listed in the following table.

Table 1. Relational Operators
Operator Meaning
= Equal.
<> Not Equal.
> Greater Than.
>= Greater Than or Equal.
< Less Than.
<= Less Than or Equal.
Like Matching a pattern.
Not Like Not matching a pattern.
Is NULL Equal to NULL.
Is Not NULL Not Equal to NULL.
Between Range of values between a lower and upper bound.
In A member of a set of specified values or a member of a subquery.
Exists True if a subquery returned at least one record.
Any Compares a value to each value returned by a subquery. Any must be prefaced by =, <>, >, >=, <, or <=.=Any is equivalent to In.
All Compares a value to each value returned by a subquery. All must be prefaced by =, <>, >, >=, <, or <=.

The following list shows some examples of relational operators:

salary <= 40000
dept = 'D101'
hire_date > {01/30/1989}
salary + commission >= 50000
last_name LIKE 'Jo%'
salary IS NULL
salary BETWEEN 10000 AND 20000
WHERE salary = ANY (SELECT salary FROM emp WHERE dept = 'D101')
WHERE salary > ALL (SELECT salary FROM emp WHERE dept = 'D101')