Can I get a query row by index in ColdFusion?

cfml, cfquery, coldfusion

Solution

You can't get a row in CF <= 10. You have to get a specific column.

<cfset x = QueryName.columnName[5]>

It's been 8 years since I posted this answer, however. Apparently CF11 finally implemented that feature. See this answer.

Problem

I want to get a specific row in a ColdFusion Query object without looping over it. I'd like to do something like this: ``` <cfquery name="QueryName" datasource="ds"> SELECT * FROM tablename </cfquery> <cfset x = QueryName[5]> ``` But it's giving me an error saying that the query isn't indexable by "5". I know for a fact that there are more than 5 records in this query.

Original source