coldfusion Database Queries Basic Example

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

Database connections are set up using the CF Administrator tool. See Database Connections for how to connect a datasource.

To execute queries all you need is the <cfquery> tag. The <cfquery> tag connects to and opens the database for you, all you need to do is supply it with the name of the datasource.

<cfquery name="Movies" datasource="Entertainment">
    SELECT title
    FROM   Movies
</cfquery>

To display the query results:

<cfoutput query="Movies">
    #title#<BR>
</cfoutput>


Got any coldfusion Question?