Computing.Net > Forums > Programming > COLDFUSION - Multiple CFQUERY Stmts

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

COLDFUSION - Multiple CFQUERY Stmts

Reply to Message Icon

Name: storminspank
Date: April 28, 2005 at 17:03:24 Pacific
OS: WinXP Pro
CPU/Ram: 2.8 / 1.0 GB
Comment:


Here's my code...

-------

<cfquery name="Recordset1" datasource="MainInventory">
SELECT *
FROM dbo.tbl_Main
LEFT JOIN dbo.tbl_Order
ON dbo.tbl_Main.Reference_Code = dbo.tbl_Order.Reference_Code
WHERE dbo.tbl_Main.Prep_Date <> '1/1/1900' AND dbo.tbl_Main.Fleet_Delivery_Date IN ('1/1/1900',' ')
ORDER BY dbo.tbl_Main.Stock_Number
ASC
</cfquery>

<cfquery name="Recordset2" datasource="ElitePlus_Internal">
SELECT * FROM dbo.Vehicle WHERE StockNo = '#Recordset1.Stock_Number#'
</cfquery>

<cfloop query="Recordset1"> <cfoutput>
<tr>
<td>#Recordset1.Stock_Number#</td>
<td>#Recordset2.VehID#</td>
<td>#Recordset1.GSO_Number#</td>
<td>#Recordset2.Model#</td>
<td>

<cfif #Recordset1.NTG_Delivery_Date# EQ "01/01/1900">
- - - -
<cfelse>
#LSDateFormat(Recordset1.NTG_Delivery_Date,'M/DD/YY')#

</cfif>
</td>
<td>

<cfif #Recordset1.Prep_Date# EQ "01/01/1900">
- - - -
<cfelse>
#LSDateFormat(Recordset1.Prep_Date,'M/DD/YY')#

</cfif>
</td>
<td>

<cfif #Recordset1.Fleet_Delivery_Date# EQ "01/01/1900">
- - - -
<cfelse>
#LSDateFormat(Recordset1.Fleet_Delivery_Date,'M/DD/YY')#

</cfif>
</td> </tr>
</cfoutput>
</cfloop>


I am trying to pull information from two databases via two separate, yet incorporated cfquery.
Yet the output gives me the same repeated field value for

Recordset2.Model and Recordset2.VehID

I want those values to change based on which Stock_Number is running in the first query.



Sponsored Link
Ads by Google

Response Number 1
Name: storminspank
Date: April 29, 2005 at 09:11:21 Pacific
Reply:

I figured it out...

Ran a THIRD query that combined the RESULTS of the first two.

<cfquery name="Recordset1" datasource="DB1">
SELECT *
FROM dbo.tbl_Main
LEFT JOIN dbo.tbl_Order
ON dbo.tbl_Main.Reference_Code = dbo.tbl_Order.Reference_Code
WHERE dbo.tbl_Main.Prep_Date <> #CreateODBCDate("1/1/1900")#
AND (dbo.tbl_Main.Fleet_Delivery_Date = #CreateODBCDate("1/1/1900")# OR dbo.tbl_Main.Fleet_Delivery_Date Is Null)
ORDER BY dbo.tbl_Main.Stock_Number
ASC
</cfquery>

<cfquery name="Recordset2" datasource="DB2">
SELECT * FROM dbo.Vehicle
</cfquery>

<CFQUERY NAME="combined" DBTYPE="query">
SELECT *
FROM Recordset1, Recordset2
WHERE Recordset2.StockNo = Recordset1.Stock_Number
</CFQUERY>

Thanks!


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: COLDFUSION - Multiple CFQUERY Stmts

ColdFusion help required www.computing.net/answers/programming/coldfusion-help-required/8952.html

Large Number Multiplication www.computing.net/answers/programming/large-number-multiplication/8682.html

[VB 6] Multiple inputs to output www.computing.net/answers/programming/vb-6-multiple-inputs-to-output/14662.html