>
> I have 2 queries which require to loop through for certain execution.
> However I discovered something
>
> <cfloop query="query_a">
>     <cfoutput>#query_a.field_a#<cfoutput>
>         <cfloop query="query_b">
>                 <cfoutput>#query_a.field_a#<cfoutput>
>         </cfloop>
> </cfloop>
>
> I realised that both #query_a.field_a# are different values, for the first
> one, it is able to list out all the different values. However for
> the second
> one, it only output the first value throughout.
>
> Is it something to do with multiple <cfloop>s ?
>
> Can somebody enlighten me on this ?
>

Eh....

OK - if you get this result set from your query a and query b :

QueryA  QueryB
FieldA  Yourfield
1         a
2       b
3       c

What you're going to get output is this:
*       1
        1
        1
        1
*       2
        2
        2
        2
*       3
        3
        3
        3

The rows marked with a * are displayed in the outer loop and the other are
displayed in the inner loop.

The reason for this is that your inner loop is only going to loop round the
contents of QueryB and output the _current row_ from QueryA. On the first
iteration of the loop on QueryA the displayed result is "1", then the inner
loop iterates through QueryB, but doesn't move onto the next record in
QueryA.  This means that for every iteration of QueryB on the first time
round the QueryA loop you'll only get the result "1".

Are you sure that you have specified your code snippet correctly and is
there something else that you are doing in the loop that is missing from the
above snippet???

Regards

Stephen

------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to