newtomysql
Technical User
Dear All,
I have a query labelled as Query1 and it works perfectly fine and fast even to a remote pc. Unfortunately I have another query to run which now I run based on each value of the receiptID which I have labelled as query2. The problem I cant join it into my query1 is that for each receiptIID I have may have a match of more than one line in tblPaymentDetails so if I do a join I will only get of the paymentdetails row. The problem here is that when I run the Query2 based on Query1 results I am running two queries and this causes my entire system to slow down badly. Is there an thing I can improve here? Thanks.
Query1 = Select Cast(Concat(tblOutlet.outletCode,tblReceipt.receiptID) As Char) as receiptID,
tblOutlet.outletCode,
tblEmployee.employeeUserName,
tblProduct.productCode,
tblReceiptDetails.productSIQ,
tblReceiptDetails.sellingPrice,
tblReceipt.receiptID,
tblReceipt.outletID
From tblReceipt
Inner Join tblReceiptDetails On
tblReceipt.receiptID = tblReceiptDetails.receiptID
And tblReceipt.outletID = tblReceiptDetails.outletID
Inner Join tblEmployee On
tblReceipt.employeeID = tblEmployee.employeeID
Inner Join tblProduct On
tblReceiptDetails.productID = tblProduct.productID
Inner Join tblOutlet On
tblReceipt.outletID = tblOutlet.outletID
Where tblReceipt.receiptDate Between
'2009-01-01' And '2009-01-18' Order By tblReceipt.receiptDate
Query2=Select tblPaymentDetails.paymentTypeID,
tblPaymentDetails.creditCardTypeID,
tblPaymentDetails.amount
From tblPaymentDetails
Where tblPaymentDetails.receiptID=+ Convert.ToInt32(myReader1.GetValue(8).ToString()) +
And tblPaymentDetails.outletID=" + Convert.ToInt32(myReader1.GetValue(9).ToString());
I have a query labelled as Query1 and it works perfectly fine and fast even to a remote pc. Unfortunately I have another query to run which now I run based on each value of the receiptID which I have labelled as query2. The problem I cant join it into my query1 is that for each receiptIID I have may have a match of more than one line in tblPaymentDetails so if I do a join I will only get of the paymentdetails row. The problem here is that when I run the Query2 based on Query1 results I am running two queries and this causes my entire system to slow down badly. Is there an thing I can improve here? Thanks.
Query1 = Select Cast(Concat(tblOutlet.outletCode,tblReceipt.receiptID) As Char) as receiptID,
tblOutlet.outletCode,
tblEmployee.employeeUserName,
tblProduct.productCode,
tblReceiptDetails.productSIQ,
tblReceiptDetails.sellingPrice,
tblReceipt.receiptID,
tblReceipt.outletID
From tblReceipt
Inner Join tblReceiptDetails On
tblReceipt.receiptID = tblReceiptDetails.receiptID
And tblReceipt.outletID = tblReceiptDetails.outletID
Inner Join tblEmployee On
tblReceipt.employeeID = tblEmployee.employeeID
Inner Join tblProduct On
tblReceiptDetails.productID = tblProduct.productID
Inner Join tblOutlet On
tblReceipt.outletID = tblOutlet.outletID
Where tblReceipt.receiptDate Between
'2009-01-01' And '2009-01-18' Order By tblReceipt.receiptDate
Query2=Select tblPaymentDetails.paymentTypeID,
tblPaymentDetails.creditCardTypeID,
tblPaymentDetails.amount
From tblPaymentDetails
Where tblPaymentDetails.receiptID=+ Convert.ToInt32(myReader1.GetValue(8).ToString()) +
And tblPaymentDetails.outletID=" + Convert.ToInt32(myReader1.GetValue(9).ToString());