Using SQL with ColdFusion
37
Writing SQL and CFML statements to interact with a data source
After ColdFusion makes a connection to the data source, you can interact with that database by
using SQL and ColdFusion.
To interact with an established data source, you must include SQL statements in your CFML
statements; for example:
<cfquery name="queryname" datasource="namedbfile">
SELECT FirstName, LastName, DepartmentID
From Employee
</cfquery>
In this example, the first attribute of the
cfquery
tag is the name of the query. The second
attribute of the
cfquery
tag defines the name of the data source. The
SELECT
statement defines
the fields (columns) to be retrieved from a table named Employee.
CFML tags that interact with a database
The following table lists the CFML tags that you can use to interact with a database:
Part II of this manual introduces these tags when you use them to interact with the sample
database. For more information about interacting with a database, see
ColdFusion MX Developer’s
Guide
or
CFML Reference.
Tag
Description
cfquery
To retrieve (query) information in a database.
cfinsert
To add records to a database.
cfupdate
To update information in a database.
Summary of Contents for COLFUSION MX 7-GETTING STARTED BUILDING COLDFUSION...
Page 1: ...COLDFUSION MX7 Getting Started Building ColdFusion MX Applications...
Page 6: ...6 Contents...
Page 10: ......
Page 14: ...14 Chapter 1 Introducing ColdFusion MX...
Page 38: ...38 Chapter 3 Database Fundamentals...
Page 40: ......
Page 58: ...58 Chapter 5 Lesson 2 Configuring Your Development Environment...
Page 70: ...70 Chapter 6 Lesson 3 Retrieving Data...
Page 84: ...84 Chapter 7 Lesson 4 Building Dynamic Queries...
Page 96: ...96 Chapter 8 Lesson 5 Creating a Trip Detail Page...
Page 102: ...102 Chapter 9 Lesson 6 Creating a Main Application Page...