User Guide

Table Of Contents
512 Chapter 22: Using Query of Queries
Query of Queries is less efficient for joins in which the predicate contains multiple expressions;
for example:
SELECT T1.a, b, c, d FROM T1, T2
WHERE T1.a = T2.a AND T1.b + T1.c = T2.b + T2.c
Understanding Query of Queries processing
The following discussions describe how Query of Queries handles the following:
Column comparisons
Queries passed by reference
Complex objects
Comparing columns with different data types
ColdFusion MX 7 includes enhancements that allow you to compare columns with different data
types.
If one of the operands has a known column type (only constants have an unknown column type),
Query of Queries tries to coerce the constant with an unknown type to the type of the operand
with metadata. The pairs of allowed coercions are as follows:
Binary, string
Dates, string
Numeric, bigdecimal
Boolean, numeric
That is, ColdFusion MX can coerce between binary and string, but not between date and string.
If both operands have known data types, the types must be the same. The only exception is that
ColdFusion MX can coerce among integer, float, and double.
If both operands are constants, ColdFusion MX tries to coerce the values, first to the most
restrictive type, then to the least restrictive type.
First to binary then to string.
First to date then to string.
First to boolean then to numeric.
Passing queries by reference
A Query of Queries is copied by reference from its related query; this means that ColdFusion MX
does not create a new query when you create a Query of Queries. It also means that changes to a
Query of Queries, such as ordering, modifying, and deleting data, are also applied to the base
query object.
If you do not want the original query to change, use the
Duplicate function to create a copy and
create the Query of Queries using the copied query.