Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Query with unknown column

Status
Not open for further replies.

Kleptican

MIS
Feb 23, 2006
26
US
I am trying to select a specific column from a database, however the column name is unknown. The columns range from FullTime_01_D to FullTime_95_D. The only thing that changes is obviously the numbers in the middle, which I can find out with no problem.

I've set up a query like so:

Code:
<CFSET query="SELECT " & #FTDeduction# & " FROM Rates_New WHERE Rates_New.ID = 1>

<cfquery name="HMOCost" datasource="MCSD">
   #query#
</cfquery>

Note: #FTDeduction# is the the string "FullTime_" & #PayType# & "_D". Paytype determines the number in the middle.

I can output #query# and see that my query is right. However, how can I reference the column that is dynamically created as well as the result from the cfquery hmocost? In other words, I can't output the result- which is just a dollar amount.

Any help is appreciated. Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top