User Guide

Table Of Contents
About Query of Queries 491
<p>#qInstruments.name[2]# has played #qInstruments.instrument[2]# for
#qInstruments.years_playing[2]# years.</p>
</cfoutput>
</body>
</html>
2.
Save the page as queryNew.cfm in the myapps directory under the web_root directory.
3.
Display queryNew.cfm in your browser
About Query of Queries
After you have created a record set with a tag or function, you can retrieve data from the record set
in one or more dependent queries. A query that retrieves data from a record set is called a Query
of Queries. A typical use of a Query of Queries is to retrieve an entire table into memory with one
query, and then access the table data (the record set) with subsequent sorting or filtering queries.
In essence, you query the record set as if it were a database table.
Note: Because you can generate a record set in ways other than using the cfquery tag, the term In
Memory Query is sometimes used instead of Query of Queries.
Benefits of Query of Queries
Performing a Query of Queries has many benefits, including the following:
If you need to access the same tables multiple times, you greatly reduce access time, because the
data is already in memory (in the record set).
A Query of Queries is ideal for tables of 5,000 to 50,000 rows, and is limited only by the
memory of the ColdFusion MX host computer.
You can perform joins and union operations on results from different data sources.
For example, you can perform a union operation on queries from different databases to
eliminate duplicates for a mailing list.
You can efficiently manipulate cached query results in different ways. You can query a database
once, and then use the results to generate several different summary tables.
For example, if you need to summarize the total salary by department, by skill, and by job, you
can make one query to the database and use its results in three separate queries to generate the
summaries.
You can obtain drill-down, master-detail information for which you do not access the database
for the details.
For example, you can select information about departments and employees in a query, and
cache the results. You can then display the employees’ names. When users select an employee,
the application displays the employees details by selecting information from the cached query,
without accessing the database.
You can use a Query of Queries in report definitions to generate subreport data. For more
information, see “Using subreports” on page 800.