Dynamic Column Names

View: New views
4 Messages — Rating Filter:   Alert me  

Dynamic Column Names

by Kevin Huff-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hey guys. I have a question. I'm working with a mySQL table that can have any number of columns. How can I get a list of these column names? I know it is stupid but I can't for the life of find the answer anywhere.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4847
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.15

RE: Dynamic Column Names

by Paul Kukiel-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Pretty sure this only works with CF8 though.

<cfquery name="myQuery" datasource="myDSN">
select * from table
</cfquery>

<cfdump var="#myQuery.columnlist#" />

Paul.

-----Original Message-----
From: Kevin Huff [mailto:khuff@...]
Sent: Monday, October 12, 2009 2:45 PM
To: cf-newbie
Subject: Dynamic Column Names


Hey guys. I have a question. I'm working with a mySQL table that can have
any number of columns. How can I get a list of these column names? I know it
is stupid but I can't for the life of find the answer anywhere.



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4848
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.15

Re: Dynamic Column Names

by Chris Griffin-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Try this query

show columns from table_name

the resulting columns from that query are Field, Type, Null, Key,  
Default, Extra

Best of luck


Chris Griffin
chrisg@...

Oceanus World Link Services, Inc.
34 Jerome Ave, Suite 114
Bloomfield, CT 06002




On Oct 12, 2009, at 2:45 PM, Kevin Huff wrote:

>
> Hey guys. I have a question. I'm working with a mySQL table that can  
> have any number of columns. How can I get a list of these column  
> names? I know it is stupid but I can't for the life of find the  
> answer anywhere.
>
>

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4849
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.15

Re: Dynamic Column Names

by Kevin Huff-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


>Pretty sure this only works with CF8 though.
>
><cfquery name="myQuery" datasource="myDSN">
>select * from table
></cfquery>
>
><cfdump var="#myQuery.columnlist#" />
>
>Paul.
>
>Hey guys. I have a question. I'm working with a mySQL table that can have
>any number of columns. How can I get a list of these column names? I know it
>is stupid but I can't for the life of find the answer anywhere.

COLUMNLIST! How could i not see that anywhere. The sad part is I think I've used that somewhere else before. I guess that is why I'm a Newbie, or as us young'ins say n00b! Anyway thanks a lot to both of you for your help.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4850
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.15