What I need is an SQL query that joins three tables. TableA and TableB are joined on Column1 which is common to both. Rows are filtered by Column2 in TableA equalling a specific value SpecificValue1. TableB and TableC are joined by Column3 which exists in both tables. However, I need all rows from TableB regardless of whether or not there is a corresponding row in TableC.
Up to there has been no problem. However, the monkey wrench is that from TableC I only want values if Column4 in TableC is a specific value SpecificValue2, otherwise I want it to return a Null value for that row.
Here is what I have and it does not produce the Nulls I am looking for. It only produces rows if TableC Column3's specific value exists for that particular row.
SELECT TableA.Column1, TableA.Column2, TableB.Column3, TableC.Column4, TableA Column5
FROM ((TableA INNER JOIN TableB ON TableA.Column1 = TableB.Column1) LEFT OUTER JOIN TableC ON TableB.Column3 = TableC.Column3) WHERE (TableA.Column2 = SpecificValue1) AND (Table3.Column4 = SpecificValue2) ORDER BY TableA.Column5
Any help would be appreciated.
By the way, here is the actual query if you are interested:
SELECT PARTSBOOKPAGEDE TAIL.PB_ItemNo, PARTSBOOKPAGEDE TAIL.PB_ItemSuf fix, PARTSBOOKPAGEDE TAIL.PB_Qty, PARTSBOOKPAGEDE TAIL.PB_SKU, PRODUCTS.PR_Des cription, USER_DEF.UD_Sea rchable, PRODUCTS.PR_Pro ductID FROM ((PARTSBOOKPAGE DETAIL INNER JOIN PRODUCTS ON PARTSBOOKPAGEDE TAIL.PB_SKU = PRODUCTS.PR_SKU ) LEFT OUTER JOIN USER_DEF ON PRODUCTS.PR_Pro ductID = USER_DEF.UD_Pro dID) WHERE (PARTSBOOKPAGED ETAIL.PBPD_Page = ?) AND (USER_DEF.UD_In dex = 6) ORDER BY PARTSBOOKPAGEDE TAIL.PB_ItemNo, PARTSBOOKPAGEDE TAIL.PB_ItemSuf fix
Up to there has been no problem. However, the monkey wrench is that from TableC I only want values if Column4 in TableC is a specific value SpecificValue2, otherwise I want it to return a Null value for that row.
Here is what I have and it does not produce the Nulls I am looking for. It only produces rows if TableC Column3's specific value exists for that particular row.
SELECT TableA.Column1, TableA.Column2, TableB.Column3, TableC.Column4, TableA Column5
FROM ((TableA INNER JOIN TableB ON TableA.Column1 = TableB.Column1) LEFT OUTER JOIN TableC ON TableB.Column3 = TableC.Column3) WHERE (TableA.Column2 = SpecificValue1) AND (Table3.Column4 = SpecificValue2) ORDER BY TableA.Column5
Any help would be appreciated.
By the way, here is the actual query if you are interested:
SELECT PARTSBOOKPAGEDE TAIL.PB_ItemNo, PARTSBOOKPAGEDE TAIL.PB_ItemSuf fix, PARTSBOOKPAGEDE TAIL.PB_Qty, PARTSBOOKPAGEDE TAIL.PB_SKU, PRODUCTS.PR_Des cription, USER_DEF.UD_Sea rchable, PRODUCTS.PR_Pro ductID FROM ((PARTSBOOKPAGE DETAIL INNER JOIN PRODUCTS ON PARTSBOOKPAGEDE TAIL.PB_SKU = PRODUCTS.PR_SKU ) LEFT OUTER JOIN USER_DEF ON PRODUCTS.PR_Pro ductID = USER_DEF.UD_Pro dID) WHERE (PARTSBOOKPAGED ETAIL.PBPD_Page = ?) AND (USER_DEF.UD_In dex = 6) ORDER BY PARTSBOOKPAGEDE TAIL.PB_ItemNo, PARTSBOOKPAGEDE TAIL.PB_ItemSuf fix