Hello,
Refer to the attached file, I have five tables tblA, tblB, tblC, tblX, and tblY.
tblA related to tblB many-to-many through tblC, I found records in tblA with no related record in tblB by executing qryA_Missing_C in the attached file:
Code:
SELECT tblA.ID_A
, tblA.AttrX_A
, tblA.AttrY_A
, tblA.Attr01_A
, tblA.Attr02_A
, tblA.Attr03_A
FROM tblA
WHERE ID_A
NOT IN
(SELECT ID_CA FROM tblC
WHERE ID_CA = ID_A)
ORDER BY 1;
I want to add attributes from tblX and tblY to the result by executing qryA_Missing_C02 resulting in no records found. There are records in tblX and tblY that matches the result query qryA_Missing_C but even if the record does not exist in either tblX or tblY it should still return NULL in the attributes. The syntax might got me on this one. Changing INNER JOIN into LEFT JOIN does not work, Access consider that as invalid statement. There is similarity with the one I post before however the difference is significant enough that I cannot use the same formula as before.
Code:
SELECT tblA.ID_A
, tblA.AttrX_A
, tblA.AttrY_A
, tblA.Attr01_A
, tblX.X_Date
, tblY.Y_Date
, tblC.ID_CB
, tblC.ID_CA
FROM tblB
INNER JOIN ((tblY INNER JOIN (tblX
INNER JOIN tblA ON tblX.X_ID = tblA.AttrX_A) ON tblY.Y_ID = tblA.AttrY_A)
INNER JOIN tblC ON tblA.ID_A = tblC.ID_CA) ON tblB.ID_B = tblC.ID_CB
WHERE (Not (tblC.ID_CA)=[tblA].[ID_A]);
Thank you again.