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::
Query Properties | |
---|---|
Property | Description |
RecordCount | The total number of records returned by the query. |
ColumnList | Returns a comma-delimited list of the query columns. |
CurrentRow | The current row of the query being processed by CFOUTPUT. |
![]() |
To output query data on your page: |
emplist.cfm
in Studio.
<HTML> <HEAD> <TITLE>Employee List</TITLE> </HEAD> <BODY> <H1>Employee List</H1> <CFQUERY NAME="EmpList" DATASOURCE="CompanyInfo"> SELECT FirstName, LastName, Salary, Contract FROM Employees </CFQUERY> <CFOUTPUT QUERY="EmpList"> #FirstName#, #LastName#, #Salary#, #Contract#<BR> </CFOUTPUT>
<CFOUTPUT> The query returned #EmpList.RecordCount# records. </CFOUTPUT></BODY> </HTML>
emplist.cfm
.
The number of employees now appears below the list of employees.
You now display the number of records retrieved in the query.
Code | Description |
---|---|
<CFOUTPUT> | Display what follows |
The query returned | Display the text "The query returned" |
#EmpList.RecordCount# | Display the number of records retrieved in the EmpList query |
records. | Display the text "records" |
</CFOUTPUT> | End the CFOUTPUT block. |
Keep the following in mind when using query properties: