User Guide

Table Of Contents
About Query of Queries 493
</cfoutput>
<p>Columns in the detail query:</p>
<cfoutput>
#detail.columnlist#<br>
</cfoutput>
2.
Save the page as query_of_query.cfm in the myapps directory under the web_root.
3.
Display query_of_query.cfm in your browser
Reviewing the code
The master query retrieves the entire Employee table from the cfdocexamples data source. The
detail query selects only the three columns to display for employees with the specified last name.
The following table describes the code and its function:
Displaying record set data incrementally
If your database is large, you can limit the number of rows displayed at one time. The following
example shows how to use the
currentRow query variable of a Query of Queries to do this. For
more information on query variables, see “Getting information about query results” on page 471.
Code Description
cfset LastNameSearch="Doe"
Sets the last name to use in the detail query. In a
complete application, this information comes
from user interaction.
<cfquery datasource="cfdocexamples"
name="master"
cachedwithin=#CreateTimeSpan(0,1,0,0)#>
SELECT * from Employee
</cfquery>
Queries the cfdocexamples data source and
selects all data in the Employees table. Caches
the query data between requests to this page,
and does not query the database if the cached
data is less than an hour old.
<cfquery dbtype="query" name="detail">
SELECT Emp_ID, FirstName, LastName
FROM master
WHERE LastName=<cfqueryparam
value=”#LastNameSearch#"
cfsqltype=”cf_sql_char”
maxLength="20"></cfquery>
Uses the master query as the source of the data
in a new query, named detail. This new query
selects only entries that match the last name
specified by the
LastNameSearch variable. The
query also selects only three columns of data:
employee ID, first name, and last name. The
query uses the
cfqueryparam tag to prevent
passing erroneous or harmful code.
<cfoutput query=detail>
#Emp_ID#: #FirstName# #LastName# <br>
</cfoutput>
Uses the detail query to display the list of
employee IDs, first names, and last names.
<cfoutput>
#master.columnlist#<br>
</cfoutput>
Lists all the columns returned by the master
query.
<cfoutput>
#detail.columnlist#<br>
</cfoutput>
Lists all the columns returned by the detail
query.