Hi, I have read a few other threads on this subject and still can't seem to get to the bottom of my problem.
I have three tables in my report: Product, Orders, RMA_Credit
Product to Orders should be an equal join and Orders to RMA_Credit should be the left outer join.
What I am trying to achieve is to see all order lines regardless of whether there are any RMA_Credit entries. However, if I have one order which contains three order lines in my order table, I only see one row returned - the one which does not have an entry in the RMA_Credit table. The other two rows do have an entry in the RMA_Credit table but they are not being displayed in the report.
If the order only has one row and this has an entry on the RMA_Credit table, everything displays correctly.
The SQL in my report is as follows:
select T1.`OrderId`, T1.`Website`, T1.`Name`, T1.`Address1`, T1.`Town`, T1.`Address3`, T1.`Country`, T1.`Postcode`, T1.`Order_Date`, T1.`Despatch_Date`, T1.`Status`, T1.`Product_ID`, T1.`Quantity`, T1.`ProductPrice` - (T1.`ProductPrice` / 100) * 17.5, T1.`Quantity` * (T1.`ProductPrice` - (T1.`ProductPrice` / 100) * 17.5), T3.`RMA_CREDIT_NUM`, T3.`CREDIT_DATE`, T3.`RMA_Credit_Reason`
from `orders` T1 LEFT OUTER JOIN `RMA_CREDIT` T3 on T1.`OrderId` = T3.`OrderID` and T1.`Product_ID` = T3.`Product_ID`
order by T1.`Product_ID`
select T2.`product only`, T2.`Product`, T2.`product_desc`, T2.`unit_quantity`, T2.`unit_cost` - (T2.`unit_cost` / 100) * 17.5, T2.`product_id`
from `product` T2
order by T2.`product_id`
Any ideas greatfully received.
I have three tables in my report: Product, Orders, RMA_Credit
Product to Orders should be an equal join and Orders to RMA_Credit should be the left outer join.
What I am trying to achieve is to see all order lines regardless of whether there are any RMA_Credit entries. However, if I have one order which contains three order lines in my order table, I only see one row returned - the one which does not have an entry in the RMA_Credit table. The other two rows do have an entry in the RMA_Credit table but they are not being displayed in the report.
If the order only has one row and this has an entry on the RMA_Credit table, everything displays correctly.
The SQL in my report is as follows:
select T1.`OrderId`, T1.`Website`, T1.`Name`, T1.`Address1`, T1.`Town`, T1.`Address3`, T1.`Country`, T1.`Postcode`, T1.`Order_Date`, T1.`Despatch_Date`, T1.`Status`, T1.`Product_ID`, T1.`Quantity`, T1.`ProductPrice` - (T1.`ProductPrice` / 100) * 17.5, T1.`Quantity` * (T1.`ProductPrice` - (T1.`ProductPrice` / 100) * 17.5), T3.`RMA_CREDIT_NUM`, T3.`CREDIT_DATE`, T3.`RMA_Credit_Reason`
from `orders` T1 LEFT OUTER JOIN `RMA_CREDIT` T3 on T1.`OrderId` = T3.`OrderID` and T1.`Product_ID` = T3.`Product_ID`
order by T1.`Product_ID`
select T2.`product only`, T2.`Product`, T2.`product_desc`, T2.`unit_quantity`, T2.`unit_cost` - (T2.`unit_cost` / 100) * 17.5, T2.`product_id`
from `product` T2
order by T2.`product_id`
Any ideas greatfully received.