In between the begin and end cfquery tags, write the SQL that you want the database to execute.
For example, to retrieve data from a database:
|
Tip If you are using ColdFusion Studio, you can use the Query Builder to build SQL statements by graphically selecting the tables and records within those tables that you want to retrieve. |
When the database processes the SQL, it creates a data set (a structure containing the requested data) that is returned to ColdFusion Server. ColdFusion places the data set in memory and assigns it the name that you defined for the query in the name attribute of the cfquery tag.
You can reference that data set by name using the cfoutput tag later on the page.
The following sections present brief descriptions of the main SQL command elements.
A SQL statement always begins with a SQL verb. The following keywords identify commonly used SQL verbs:
| Keyword |
Description |
|---|---|
| SELECT |
Retrieves the specified records |
| INSERT |
Adds a new row |
| UPDATEw |
Changes values in the specified rows |
| DELETE |
Removes the specified rows |
Use the following keywords to refine SQL statements:
The following basic operators specify conditions and perform logical and numeric functions:
When writing SQL in ColdFusion, keep the following guidelines in mind:
cfquery, so you are free to use any syntax that is supported by your data source. Check your DBMS documentation for nonstandard SQL usage.LiveDocs comments are not longer enabled for ColdFusion 5.0. Please use one of the following resources instead.
ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting
Version 5.0