Avg. Rating 3.5

Problem

You don't want to loop over a query (CFQUERY result set) but access the Nth row or the last row.

Solution

You can access a query row by adding its number to the query.column variable.

Detailed explanation

You can access a query row by adding its number to the query.column variable:

To get the column "firstname" in the 2nd row use: queryName.firstName[2]
To get the column "firstname" in the last row use: queryName.firstName[queryName.recordCount]
To get the column "firstname" in the Nth row use: queryName.firstName[N]


+
This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

Report abuse

Related recipes