Entering content frame

Comparison Predicate (comparison_predicate) Locate the document in the library structure

A comparison predicate (comparison_predicate) is a predicate that specifies a comparison between two values or lists of values.

Syntax

<comparison_predicate> ::=
  <
expression> <comp_op> <expression>
| <expression> <comp_op> <
subquery>
| <
expression_list> <equal_or_not> (<expression_list>)
| <expression_list> <equal_or_not> <subquery>

The following relational operators are available for comparing two values:
<comp_op> ::= < | > | <> | != | = | <= | >=
            |
~= <!  for computers with ASCII code !>
            |
~< <!  for computers with ASCII code   !>
            |
~> <!  for computers with ASCII code   !>

Only the following relational operators are available to compare two value lists:
<equal_or_not> ::= <> |=
                 | ~= (for computers with ASCII code)

Examples

SQL Tutorial, Structure linkConditions: Comparison, AND, OR, BETWEEN, IN, Structure linkSubquery: Inner Queries

Explanation

The subquery must supply a result table that contains the same number of columns as the number of values on the left of the operator. The result table may contain no more than one row.

The list of values specified to the right of the equal_or_notoperator expression_list must contain the same number of values as specified in the value list in front of the equal_or_notoperator.

The JOIN predicate is a special case.

Comparing Two Values

Let x be the result of the first expression and y the result of the second expression or of the subquery.

      The values x and y must be comparable with one another.

      Numbers are compared to one another according to their algebraic values.

      Character strings are compared character by character.
Any blanks (code attribute ASCII, UNICODE) or binary zeros (code attribute BYTE) at the end of one or both of the character strings are removed.
If the character strings have the different code attributes ASCII and UNICODE, the character string with the code attribute ASCII is implicitly converted into a character string with the code attribute UNICODE.
Two character strings are identical if they have the same characters in all positions.
The relationship between two character strings that are not identical is defined by the first character that differs in a comparison from left to right. This comparison is performed in accordance with the code attribute selected for this column (ASCII, UNICODE, or BYTE).

      If x or y are NULL values, or if the result of the subquery is empty, then (x <comp_op> y) is not defined.

Comparing Two Value Lists

If a value list expression_list is specified on the left of the comparison operator equal_or_not, x is the value list that comprises the results of the values x1, x2, ..., xn in this list. y is the result of the subquery or the result of the second value list. A value list y consists of the results of the values y1, y2, ..., yn.

      A value xm must be comparable with the associated value ym.

      x=y is true if for xm=ym for all m=1, ..., n.

      x<>y is true if at least xm<>ym for at least one m.

      (x <equal_or_not> y) is undefined (not known) if there is no m for which (xm <equal_or_not> ym) is false and if there is at least one m for which (xm <equal_or_not> ym) is undefined.

      If one xm or one ym is a NULL value, or if the result of the subquery is empty, (x <equal_or_not> y) is undefined.

See also:

Quantified Predicate

DEFAULT Predicate

 

Leaving content frame