background image

WHERE Clause

<< Expression Types | Conditional Expressions >>
<< Expression Types | Conditional Expressions >>

WHERE Clause

FROM Player AS p, IN (p.teams) t
WHERE t.league.sport =
'soccer'
WHERE
Clause
The WHERE clause specifies a conditional expression that limits the values returned by the query.
The query returns all corresponding values in the data store for which the conditional
expression is TRUE. Although usually specified, the WHERE clause is optional. If the WHERE clause
is omitted, then the query returns all values. The high-level syntax for the WHERE clause follows:
where_clause ::= WHERE conditional_expression
Literals
There are four kinds of literals: string, numeric, Boolean, and enum.
String Literals
A string literal is enclosed in single quotes:
'Duke'
If a string literal contains a single quote, you indicate the quote by using two single quotes:
'Duke''s'
Like a Java String, a string literal in the query language uses the Unicode character encoding.
Numeric Literals
There are two types of numeric literals: exact and approximate.
An exact numeric literal is a numeric value without a decimal point, such as 65,­ 233, and +12.
Using the Java integer syntax, exact numeric literals support numbers in the range of a Java
long
.
An approximate numeric literal is a numeric value in scientific notation, such as 57.,­ 85.7, and
+2.1. Using the syntax of the Java floating-point literal, approximate numeric literals support
numbers in the range of a Java double.
Boolean Literals
A Boolean literal is either TRUE or FALSE. These keywords are not case-sensitive.
Full Query Language Syntax
Chapter 27 · The Java Persistence Query Language
751