|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
declaring variables from within a query
Hi,
I was just wondering if it is possibly to set a variable from withina query. e.g <cfquery name ="somequery"> select name,age,phone from sometable <cfset myvar1 = age> </query> I need the colum from this table to be set to that variable name so i can pass it through my documents. Thanks Andy |
|
#2
|
|||
|
|||
|
Quote:
I'm confused. Are you trying to set myvar1 to the column name age or the value of age? <cfset myvar1 = "age"> or <cfset myvar1 = query.age> |
|
#3
|
|||
|
|||
|
I'm with Bastion in that I'm not sure what you're trying to do. You can set the variable to the name of the column, or to the value of the column (after the query is finished).
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#4
|
|||
|
|||
|
I think what he means is, is the following possible: (?)
<cfquery name="myQuery" datasource="foo"> SELECT name, age, phone FROM myTable <cfset myVar="#myQuery.age#"> </cfquery> Edit: for typo fix |
|
#5
|
|||
|
|||
|
No, that's not possible because until the query is finished and returned from the database, there is no query named "myQuery".
|
|
#6
|
|||
|
|||
|
Huh?
Quote:
I guess the big question is why would you want to set a variable from inside a query? Why can you not just wait until you get the query results to set the variable? I think that if you answer that, we might be able to help you more... -Matt |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > declaring variables from within a query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|