How to print all the result without using Results.columnname in ColdFusion
for ex:-
I have <cfquery name="getProductId">
select productId
from product
</cfquery>
In Product Table i have 2 columns with product_name and Product_id.
How can I print them without using getProductId.product_name getProductId.Product_id
Thanks,
What are you trying to achieve? If you are looking for a way to computationally output query results based on a query whose column names you do not know, such as...
<cfquery name="queryName" ...>
select * from product
</cfquery>
...then you can use the queryName.ColumnList
variable, which returns a comma separated list of all column names. You could subsequently iterate over this list, and output as required.
For example, to get a simple HTML table output:
<table border=1>
<cfloop from="0" to="#queryName.RecordCount#" index="row">
<cfif row eq 0>
<tr>
<cfloop list="#queryName.ColumnList#" index="column" delimiters=",">
<th><cfoutput>#column#</cfoutput></th>
</cfloop>
</tr>
<cfelse>
<tr>
<cfloop list="#queryName.ColumnList#" index="column" delimiters=",">
<td><cfoutput>#queryName[column][row]#</cfoutput></td>
</cfloop>
</tr>
</cfif>
</cfloop>
</table>
Apologies if this isn't what you meant!