Skip to main content
Inspiring
February 26, 2009
Question

get a list of all field names

  • February 26, 2009
  • 3 replies
  • 1440 views
I forgot the sql statement - how do I get a list of all field names in a table?
    This topic has been closed for replies.

    3 replies

    revdaveAuthor
    Inspiring
    February 26, 2009
    I just saw this - is it STILL true (*sorted alphabetically*;)?
    Is there any way to get the list in ORIGINAL order?


    - - - - -
    From: ColdFusion MX 7 -- ColdFusion tag-specific variables -- Version 7
    Location: http://livedocs.adobe.com/coldfusion/7/htmldocs/wwhelp/wwhimpl/common/html/wwhelp.htm?context=ColdFusion_Documentation&file=00000192.htm
    - - - - -

    Info:
    Oblio said on Mar 21, 2006 at 8:59 AM :
    It's really critical to note that query.ColumnList is *sorted alphabetically*; it does not display a list of columns in the order that they were returned from the database. This is also true for queries created by the QueryNew function.

    Inspiring
    February 26, 2009
    Don't use select *. Invariably you'll bring back more data than you need. Another approach is:

    fields = "f1,f2,etc";

    select #fields# from yourtable

    <cfoutput query="yourquery">
    <cfloop list = "#fields#" index = "ii">
    #yourquery[ii]#
    revdaveAuthor
    Inspiring
    February 26, 2009
    quote:

    Originally posted by: Dan Bracuk
    Don't use select *. Invariably you'll bring back more data than you need. Another approach is:

    fields = "f1,f2,etc";

    select #fields# from yourtable

    <cfoutput query="yourquery">
    <cfloop list = "#fields#" index = "ii">
    #yourquery[ii]#




    Hi Dan - thanks much for you help.

    I'm a bit confused - i don't have the fields yet - that's what I'm trying to get - so I don't know how to use:
    yours .....fields = "f1,f2,etc";

    anyway

    - actually I said:

    <cfquery ...........
    select * from mytable where id = 1
    </query ............

    then

    <cfoutput .....
    #queryname.ColumnList#
    </cfoutput........

    which DOES work - BUT i need it to output in *ORIGINAL* order from the database (MS ACCESS) - (currently it is not that)


    thanks again
    revdaveAuthor
    Inspiring
    February 26, 2009
    BTW: I need it for ms ACCESS & MS sequel server...

    i think i got it working with

    queryname.ColumnList


    q: but how do I get it to sort from the order it is in the database?