• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 15. Structures > Queries as Structures

Queries as Structures

ColdFusion query record sets are complex data types. Although they are neither structures nor arrays, they do have similarities to both. You can refer to a query using the standard queryname.columname syntax, much as with a structure. Yet because there are multiple records within a query, you also can refer to a query as queryname.columname[recordnumber]. Consider the following example:

<cfquery name="users"
         datasource="dsn">
SELECT LastName, Firstname
FROM users
ORDER BY Lastname, FirstName
</cfquery>

<!--- <cfloop> through the results --->
<cfloop from="1" to="#users.RecordCount#" index="i">
 <cfoutput>
 #i#: #users.LastName[i]# #users.FirstName[i]#
 </cfoutput><br>
</cfloop>


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint