I have three tables (the example is a scaled-down version but structurally accurate):
theader -- header info about a customer
tdetail -- details about specific interactions with the customer
tanalyst -- a table storing employee names
The problem seems to be that I'm using tAnalyst as a lookup value in both tHeader and tDetail (an analyst might 'own' a customer, i.e., be stored in the header, and a totally different analyst might have some specific interaction with the customer and be stored in the detail table).
So there's a relationship between theader and tanalyst and a second relationship between tdetail and tanalyst.
This query acts appropriately, returning all the records in the detail table:
Expand|Select|Wrap|Line Numbers
- SELECT tHeader.MA, tDetail.CurrentAnalyst
- FROM tHeader INNER JOIN tDetail ON tHeader.MA = tDetail.MA;
Expand|Select|Wrap|Line Numbers
- SELECT tHeader.MA, tDetail.CurrentAnalyst, tAnalysts.AnalystName
- FROM tAnalysts INNER JOIN (tHeader INNER JOIN tDetail ON tHeader.MA = tDetail.MA) ON (tAnalysts.AnalystID = tDetail.CurrentAnalyst) AND (tAnalysts.AnalystID = tHeader.PrimaryAnalyst);