Retrieving Data

You can query databases to retrieve data at runtime. When retrieving data from a database:

The CFQUERY Tag

The CFQUERY tag is one of the most frequently used CFML tags. You use it in conjunction with the CFOUTPUT tag so that you can retrieve and reference the data returned from a query.

When ColdFusion encounters a CFQUERY tag on a page, it does the following:

CFQUERY tag syntax

<CFQUERY NAME="EmpList" DATASOURCE="CompanyInfo">
    You'll type SQL here
</CFQUERY>

In this example, the query code tells ColdFusion to:

In general, you should follow these guidelines:

Note The data source must exist in order to perform a successful query.