![MACROMEDIA COLDFUSION 5-DEVELOPING Develop Manual Download Page 49](http://html1.mh-extra.com/html/macromedia/coldfusion-5-developing/coldfusion-5-developing_develop-manual_3293641049.webp)
Building Queries
29
Reviewing the code
The query you just created retrieves data from the CompanyInfo database. The
following table describes the code and its function:
Query notes and considerations
When creating queries to retrieve data, keep the following guidelines in mind:
•
Enter the query
name
and
datasource
attributes in the begin
cfquery
tag.
•
Surround attribute settings with double quotes(").
•
Make sure that a data source exists in the ColdFusion Administrator before you
reference it n a
cfquery
tag. Alternatively, use the
dbtype = "dynamic"
and
queryString
attributes to dynamically specify a database.
•
The SQL that you write is sent to the database and performs the actual data
retrieval.
•
Columns and tables that you refer to in your SQL statement must exist, otherwise
the query will fail.
•
Reference the query data by naming the query in one of the presentation tags,
such as
cfoutput
,
cfgrid
,
cftable
,
cfgraph
, or
cftree
later on the page.
Code
Description
<cfquery name="EmpList"
datasource="CompanyInfo">
Queries the database specified in the
CompanyInfo data source
SELECT FirstName, LastName,
Salary, Contract
FROM Employee
Gets information from the FirstName,
LastName, Salary, and Contract fields in
the Employee table
</cfquery>
Ends the
cfquery
block
Summary of Contents for COLDFUSION 5-DEVELOPING
Page 1: ...Macromedia Incorporated Developing ColdFusion Applications MacroMedia ColdFusion 5 ...
Page 58: ...38 Chapter 3 Querying a Database ...
Page 134: ...114 Chapter 7 Updating Your Database ...
Page 210: ...190 Chapter 10 Reusing Code ...
Page 232: ...212 Chapter 11 Preventing and Handling Errors ...
Page 238: ...218 Chapter 12 Using the Application Framework ...
Page 262: ...242 Chapter 12 Using the Application Framework ...
Page 278: ...258 Chapter 13 Extending ColdFusion Pages with CFML Scripting ...
Page 320: ...300 Chapter 15 Indexing and Searching Data ...
Page 336: ...316 Chapter 16 Sending and Receiving E mail ...
Page 374: ...354 Chapter 18 Interacting with Remote Servers ...