Coldfusion list column names

I would like to grab a list of column names from a query where the column value is GT 0. I don't want the column values, but the actual column names, which is proving to be problematic. Anyone have any ideas about how this could be done?
mjacobs2929Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CrazeeCommented:
Use the ColumnList property of the query object

<cfOutput>#queryName.ColumnList#</cfOutput>

Cheers
0
MauseCommented:
Yes Crazee is right use queryName.ColumnList to get the column names. This will return a list width all column names
like: colname1,colname2,colname3

to find out how many column names are in the list use listlen(queryveldtest.ColumnList)
and use cfloop to loop over the list of column names
0
mjacobs2929Author Commented:
Thanks,
But how do I determine which of the columns have a value EQ 1?
0
MauseCommented:
I'm not sure what you want!
Is it that you want the column name of the column where the value EQ 1

Then it will be someting like this:

<cfloop list="#queryname.ColumnList#" index="columnname">
      <cfif queryname[columnname][1] EQ 1>#columnname#</cfif>
</cfloop>

This will loop over all column fields of record 1

Let me know
Mause
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mjacobs2929Author Commented:
Got it! This is exactly what I wanted...

 <cfset request.pagelevelList="">
 <cfloop list="#getlevel.ColumnList#" index="columnname">
   <cfif getlevel[columnname][1] EQ 1>
    <cfset request.pagelevelList = ListAppend(request.pagelevelList,"#columnname#")>
   </cfif>
 </cfloop>

Many thanks to you both!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.