User Guide

32 Chapter 3 Querying a Database
Getting Information About Query Results
Each time you query a database with the cfquery tag, you get not only the data itself,
but also query properties, as described in the following table:
To output query data on your page:
1Return to emplist.cfm in ColdFusion Studio.
2 Edit the file so that it appears as follows:
<html>
<head>
<title>Employee List</title>
</head>
<body>
<h1>Employee List</h1>
<cfquery name="EmpList" datasource="CompanyInfo">
SELECT FirstName, LastName, Salary, Contract
FROM Employee
</cfquery>
<cfoutput query="EmpList">
#FirstName#, #LastName#, #Salary#, #Contract#<br>
</cfoutput>
<br>
<cfoutput>
The query returned #EmpList.RecordCount# records.
</cfoutput>
</body>
</html>
3 Save the file as emplist.cfm.
4 View the page in a browser.
The number of employees now appears below the list of employees.
Note
The variable
cfquery.executionTime contains the amount of time, in milliseconds,
it took for the query to complete. Do not prefix the variable name with the query
name.
Reviewing the code
Property Description
RecordCount The total number of records returned by the query.
ColumnList A comma-delimited list of the query columns.
CurrentRow The current row of the query being processed by
cfoutput.