Comparison expressions

Updated: May 06, 2022

QDB features the following comparison operators:

The results of a comparison depend on the storage classes of the two values being compared, based on the following rules:

QDB may attempt to convert values between the numeric storage classes (INTEGER and REAL) and TEXT before performing a comparison. For binary comparisons, this is done in the cases enumerated below. Here, the term “expression” refers to any SQL scalar expression or literal other than a column value.

In QDB, the expression a BETWEEN b AND c is equivalent to a >= b AND a <= c, even if this means that different affinities are applied to a in each of the comparisons required to evaluate the expression.

Expressions of the type a IN (SELECT b ...) are handled by the rules enumerated above for binary comparisons (e.g., in a similar manner to a = b). For example, if b is a column value and a is an expression, then the affinity of b is applied to a before any comparisons take place.

QDB treats the expression a IN (x, y, z) as equivalent to a = x OR a = y OR a = z.