5 Replies Latest reply on May 5, 2010 5:16 AM by -==cfSearching==-

    SQL query and CFOUTPUT question

    pkonshak Level 1

      Hi,

       

      I'm trying to compare two tables in a database.  I need to output a few fields from one table, compare one field between the two tables.  Users are selecting the tables.  I have written an SQL query which does what I need:

       

      <cfquery name="getitems" datasource="snapshot">
      select #endtable#.field9, #endtable#.field12, #endtable#.field4, #endtable#.field13, #endtable#.field2, #endtable#.field3, #starttable#.field3
      from #endtable#, #starttable#
      where #endtable#.field5='#form.field5#'
      and #starttable#.field2=#endtable#.field2
      </cfquery>

       

      Problem is on output.  You can see I am selecting field3 from two tables.  I also want to output both field3 values.

       

      <cfoutput query="getitems">

      #field3#

      </cfoutput>

       

      This gives me the value which was selected as #endtable#.field3.

       

      How can I output the other -- #starttable#.field3?

       

      As noted, the table names are variables being passed into the query...  Thanks!

       

      Peter