solidDB Help : solidDB reference : SQL: Expressions
  
SQL: Expressions
Comparison operators
Comparison operators compare one expression to another. The result is always TRUE, FALSE, or NULL. Typically, comparisons are used in conditional control statements and allow comparisons of arbitrarily complex expressions.
 
Operator
Meaning
=
is equal to
<>
is not equal to
<
is less than
>
is greater than
<=
is less than or equal to
>=
is greater than or equal to
!=
is not equal to
!= notation cannot be used inside a stored procedure, use the ANSI-SQL compliant <> instead.
Logical operators
The logical operators can be used to build more complex queries. The logical operators AND, OR, and NOT operate according to the tri-state logic illustrated by the following truth tables. AND and OR are binary operators; NOT is a unary operator.
Logical operators: NOT
 
NOT
true
false
null
 
false
true
null
Logical operators: AND
 
AND
true
false
null
true
true
false
null
false
false
false
false
null
null
false
null
Logical operators: OR
 
OR
true
false
null
true
true
true
true
false
true
false
null
null
true
null
null
As shown in the truth tables, AND returns the value TRUE only if both its operands are true. On the other hand, OR returns the value TRUE if either of its operands is true. NOT returns the opposite value (logical negation) of its operand. For example, NOT TRUE returns FALSE.
NOT NULL returns NULL because nulls are indeterminate.
If you do not use parentheses to specify the order of evaluation, operator precedence determines the order.
Note that "true" and "false" are not literals accepted by SQL parser but values. Logical expression value can be interpreted as a numeric variable:
false = 0 or NULL
true = 1 or any other numeric value
Example:
IF expression = TRUE THEN
can be simply written
IF expression THEN
IS NULL operator
The IS NULL operator returns the Boolean value TRUE if its operand is null, or FALSE if it is not null. Comparisons involving nulls always yield NULL. To test whether a value is NULL, do not use the expression,
IF variable = NULL THEN...
because it never evaluates to TRUE.
Instead, use the following statement:
IF variable IS NULL THEN...
Note that when using multiple logical operators in solidDB stored procedures the individual logical expressions should be enclosed in parentheses like:
((A >= B) AND (C = 2)) OR (A = 3)