1 Reply Latest reply on Mar 20, 2008 12:55 PM by Newsgroup_User

    query withing query loop

    TiGGi Level 1
      Hi all,

      This is the situation that I have
      <query1>
      <cfloop query1>
      <query2>
      <cfoutput query2>
      <cfoutput query2>
      </cfloop>
      </cfloop>
      Lets say that query2 has 2 rows, I am getting data from row1 in row2 where row2 fields are empty.
      So if I have row1 query2.name = 'mike' I'll get that same value in row2 if the row2 name is blank?
        • 1. Re: query withing query loop
          Level 7
          TiGGi wrote:
          > Hi all,
          >
          > This is the situation that I have
          > <query1>
          > <cfloop query1>
          > <query2>
          > <cfoutput query2>
          > <cfoutput query2>
          > </cfloop>
          > </cfloop>
          > Lets say that query2 has 2 rows, I am getting data from row1 in row2 where
          > row2 fields are empty.
          > So if I have row1 query2.name = 'mike' I'll get that same value in row2 if the
          > row2 name is blank?
          >


          A) Nine times out of ten when one has logic like this it can be
          simplified with a single join query and a single query output loop.

          B) When one does do logic like this, one almost always has to use fully
          qualified query references. Otherwise ColdFusion gets confused about
          what row of each query is being output and just outputs the first row.

          A fully qualified query reference is #queryName.column[row]# OR
          #queryName['column'][row]#