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> Here the record set is being treated as if it were a structure of arrays. This syntax makes it possible to directly access database results as needed. |