perhaps i'm reading this wrong, but do you have to do 2 queries for this, or can you join the tables, then group the output to get what you need?
On 3/12/07, Michael Stevens <[EMAIL PROTECTED]> wrote: > Hey guys! > > I'm new to ColdFusion and having some problems altering some old cfm pages > I've inherited as the new "IT guy." I don't know much about ColdFusion but > I've been able to stumble around and change a few things but one page > (actually, two similar pages) in particular is giving me a problem. > > We are a print shop and our website is linked to our database through CF. > We've got several "order" pages that display order numbers, order names, > stocks, inks, all kinds of print-related information. I've been asked to put > our reorder information on the order detail page so that customers can look > up a past order and order with that number and not have to submit artwork > again. > > There are two pertinent tables: QOrdLineItems and QHistRO. The first query > looks like this: > > <cfquery name="Recordset1" datasource="AR"> > SELECT OrderNum, Status, MainLine, acct_id, date, po_num FROM > "QOrdLineItems" WHERE acct_id = '#COOKIE.id#' ORDER BY date DESC > </cfquery> > > My understanding is this pulls five variables from QOrdLineItems when the > variable acct_id matches the id in the cookie being set when logged in. I > have no idea what "ORDER BY date DESC" does. > > The new reorder information I need to output is in the QHistRO table and is > in two different columns called reorder_num and control_num. I've tried a > bunch of differnet ways to call these variables and none so far have worked, > although it may be my output statements that aren't working. Currently I > have this query: > > <cfquery name="Recordset2" datasource="AR"> > SELECT reorder_num, control_num FROM "QHistRO" WHERE reorder_num = > '#Recordset1.OrderNum#' OR control_num = '#Recordset1.OrderNum#' > </cfquery> > > I'm trying to pull the variables from the table only when the > reorder_num/control_num matches the OrderNum in Recordset1 pulled from > QOrdLineItems. > > I'm outputting the variables with (the startrow & maxrows are defined > elsewhere and not causing problems): > > <table> > <cfoutput query="Recordset1" startrow="#StartRow_Recordset1#" > maxrows="#MaxRows_Recordset1#"> > <cfset realdate = > "#Mid(Recordset1.date,5,2)#-#Mid(Recordset1.date,7,2)#-#Mid(Recordset1.date, > 3,2)#"> > <tr> > <td align="center">#realdate#</td> > <td> #Recordset1.MainLine#</td> > <td align="center"><a href=/orders/ord.cfm?ID=#Recordset1.ordernum# > title="View Order Details">#Recordset1.Ordernum# <img src="/details.jpg" > border=0></a></td> > <td align="center"> #stat#</td> > <td align="center"> #Recordset1.PO_num# </td> > </cfoutput> > <td align="center"><cfoutput>#Recordset2.control_num#</cfoutput></td> > <td align="center"><cfoutput>#Recordset2.reorder_num#</cfoutput></td> > </tr> > </table> > > I have sucessfully pulled those variables into a different page and got them > to output using this code (the URL.ID is the order_num variable): > > <cfparam name="URL.ID" default="0TU45375"> > <cfparam name="URL.Ref_1" default="TU"> > <cfif #url.id# contains "NI"><cfset newnumber = #mid(url.id,2,8)#></cfif> > <cfif #url.id# contains "TU"><cfset newnumber = #mid(url.id,2,8)#></cfif> > <cfif #url.id# contains "DQ"><cfset newnumber = #mid(url.id,2,8)#></cfif> > <cfif #url.id# contains "00"><cfset newnumber = #mid(url.id,3,6)#></cfif> > > <cfquery name="HistRO" datasource="AR"> > SELECT invoice_num, reorder_num, control_num FROM "QHistRO" WHERE > reorder_num = '#URL.ID#' or control_num= '#URL.ID#' > </cfquery> > > Control #<br><cfoutput>#HistRO.control_num#</cfoutput><br> > Reorder #<br><cfoutput>#HistRO.reorder_num#</cfoutput><br> > > I don't know a lot about ColdFusion and I've actually accomplished more than > I thought I could but I'm hoping someone can help me finish this problem. > > Thanks, > > Mike > > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| ColdFusion MX7 and Flex 2 Build sales & marketing dashboard RIAâs for your business. Upgrade now http://www.adobe.com/products/coldfusion/flex2 Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:272402 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

