
Using SQL with ColdFusion
35
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 need to include SQL statements in your CFML
statements; for example:
<cfquery name="queryname" datasource="namedbfile">
SELECT FirstName, LastName, DepartmentID
From Employee
</cfquery>
In the previous example, the first attribute of
cfquery
is the name of the query. The second
attribute of
cfquery
defines the name of the data source. The
SELECT
statement defines the fields
(columns) to be retrieved from a tabled named
Employee
.
CFML tags that interact with a database
The following table lists the CFML tags you can use to interact with a database:
In Part II of this book, you will be introduced to these tags when you use them to interact with
the sample database. For more information about interacting with a database, see
Developing
ColdFusion MX Applications
or
CFML Reference.
Command
Description
cfquery
To retrieve (query) information in a database.
cfinsert
To add records to a database.
cfupdate
To update information in a database.
Содержание COLDFUSION MX 61-GETTING STARTED BUILDING COLDFUSION...
Страница 1: ...Getting Started Building ColdFusion MX Applications...
Страница 6: ...6 Contents...
Страница 10: ......
Страница 30: ...30 Chapter 2 CFML Basics...
Страница 36: ...36 Chapter 3 Database Fundamentals...
Страница 48: ......
Страница 76: ...76 Chapter 6 Lesson 2 Writing Your First ColdFusion Application...
Страница 134: ...134 Index...