Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get number of columns in a query or structure in ColdFusion

Tags:

coldfusion

Is there any expedient (preferably no loop) way to get the number of columns in a query result? I'm dealing with a module that uses a data set without knowing its details.

like image 578
jtpereyda Avatar asked Dec 03 '22 02:12

jtpereyda


2 Answers

<cfoutput>
   #ListLen(YourQuery.ColumnList)#
</cfoutput>
like image 83
Stefano D Avatar answered Jan 06 '23 00:01

Stefano D


<cfquery name="myQuery" datasource="#dsn#">
SELECT * FROM myTable
</cfquery>

<cfoutput>#myQuery.columnList#</cfoutput>
like image 40
orangepips Avatar answered Jan 06 '23 00:01

orangepips