Coldfusion list column names

Posted on 2004-11-16
Last Modified: 2013-12-20
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?
Question by:mjacobs2929
    LVL 2

    Assisted Solution

    Use the ColumnList property of the query object


    LVL 10

    Expert Comment

    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

    Author Comment

    But how do I determine which of the columns have a value EQ 1?
    LVL 10

    Accepted Solution

    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>

    This will loop over all column fields of record 1

    Let me know

    Author Comment

    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#")>

    Many thanks to you both!

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Introduction In this tutorial, I'll explain how to create an animated progress meter in a wireframe prototype developed using Axure RP 7.0 - a leading prototyping tool for designing web sites and software. (For more information about Axure and gett…
    If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
    The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be Log into your Hosting account. IPage will be used for demonstration : Locat…
    The purpose of this video is to demonstrate how to Test the speed of a WordPress Website. Site Speed is an important metric of a site’s health. Slow site speed can result in viewers leaving your site quickly and not seeing your content. This…

    730 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now