Java Reference
In-Depth Information
WHERE c.categoryName = 'Dumped Cars'
OR c.categoryName = 'Furniture from Garbage'
You can use all types of relational operators with numeric types of path expressions.
String
and
Boolean
operands can use the relational operators: equality (
=
) and
nonequality (
<>
).
Using a range with BETWEEN
You can use the
BETWEEN
operator in an arithmetic expression to compare a variable with
a range of values. You can also use the
BETWEEN
operator in arithmetic, string, or date-
time expressions to compare a path expression to a lower and upper limit using the follow-
ing syntax:
path_expression [NOT] BETWEEN lowerRange and upperRange
Suppose you want to filter the results so that
categoryId
falls within a specified range.
You can use a
WHERE
clause and named parameters for the range this way:
WHERE c.categoryId BETWEEN :lowRange AND :highRange
Note
The lower and upper range used in a
BETWEEN
operator must be the same data type.
Using the IN operator
The
IN
operator allows you to create a conditional expression based on whether a path ex-
pression exists in a list of values. Here is the syntax for the
IN
operator:
path_expression [NOT] IN (List_of_values)
The list of values can be a static list of comma-separated values or a dynamic list retrieved
by a subquery. Suppose you want to retrieve the results for
userId
that exist in a static
list of
userId
s. This
WHERE
clause will do the trick:
WHERE u.userId IN ('viper', 'drdba', 'dumpster')