![]() ![]() ![]() |
||
|
Relational database management systems process SQL instructions sent to them from various applications. ColdFusion sends SQL statements to database managers to manipulate data. ColdFusion needs a way to know to which database manager to send a specific SQL string for evaluation. In CFML, the cfquery
tag serves this purpose. You will use the SQL SELECT statement and the cfquery
tag to create a dynamic version of the Trip List page described earlier in this lesson. In this example, you use the cfquery
tag to return all the trip names found in the tripName column in the Compass Travel Trips table. To use the SQL SELECT statement to dynamically retrieve this information, you must execute the SQL SELECT statement between the cfquery
start and end tags.
Note: If you are working in Dreamweaver, ensure that you select ColdFusion Templates in the Save As Type list.
<cfquery name="TripList" datasource="CompassTravel"> SELECT trips.tripName FROM trips </cfquery>
Dreamweaver lets you create a query without having to enter the code.
Your ColdFusion application page retrieves the information for the trip list. Next, you need to display the information.
The following table describes the code used to build the query:
Code |
Explanation |
---|---|
<cfquery name="TripList" datasource="CompassTravel"> |
ColdFusion query named TripList. Submits any SQL statement between the |
SELECT trips.tripName FROM trips |
SQL SELECT statement to retrieve all tripName(s) from the trips table. |
|
||
![]() ![]() ![]() |