background image
<< Expression precedence | Explanation and Example >>

Boolean expressions

<< Expression precedence | Explanation and Example >>
Derby Reference Manual
97
(age < 16 OR age > 65) AND employed = TRUE
Boolean expressions
Boolean expressions are allowed in WHERE clauses and in check constraints. Boolean
expressions in check constraints have limitations not noted here; see
CONSTRAINT
clause
for more information. Boolean expressions in a WHERE clause have a highly
liberal syntax; see
WHERE clause
, for example.
A boolean expression can include a boolean operator or operators. These operators are
listed in the following table.
Table 6.
SQL Boolean operators
Operator
Explanation and Example
Syntax
AND, OR, NOT
Evaluate any operand(s) that are
boolean expressions
(orig_airport = 'SFO') OR
(dest_airport = 'GRU')
-- returns true
{
Expression AND
Expression |
Expression OR
Expression |
NOT Expression
}
Comparisons
<, =, >, <=, >=, <> are applicable to all
of the built-in types.
DATE('1998-02-26') <
DATE('1998-03-01')
-- returns true
Note: Derby also accepts the !=
operator, which is not included in the
SQL standard.
Expression
{
< |
= |
> |
<= |
>= |
<>
}
Expression
IS NULL, IS NOT
NULL
Test whether the result of an
expression is null or not.
WHERE MiddleName IS NULL
Expression IS [ NOT
]
NULL
LIKE
Attempts to match a character
expression to a character pattern,
which is a character string that
includes one or more wildcards.
% matches any number (zero
or more) of characters in the
corresponding position in first
character expression.
_ matches one character in the
corresponding position in the
character expression.
Any other character matches only
that character in the corresponding
position in the character expression.
city LIKE 'Sant_'
To treat % or _ as constant
characters, escape the character with
CharacterExpression
[ NOT ] LIKE

CharacterExpression
WithWildCard
[ ESCAPE
'escapeCharacter']