I have two queries that I'm trying to left join together based on three fields. When I do, I'm getting the results of an INNER join (only the two records that match in both queries). If I remove one of the fields from the join (making the join on two fields), then I get the results that I'm looking for - all the records from the left table and the two records that match up.
Here is the query with the three fields left joined that isn't working:
Here is the same query, but only joined on two fields that works.
Is there some syntax that I'm missing to make it work with three fields in the join? I've played around with the parenthesis, adding a set around the entire ON clause, as I saw on one article I found while Googling the issue, but no change. What am I missing?
Here is the query with the three fields left joined that isn't working:
Code:
SELECT Base.LoanId_fk , Base.TaskId_pk , Base.Description , Base.TaskOrder , Base.ValueLocation , LoanValue.FieldName , LoanValue.FieldValue FROM tqryTasks_Pro_Base AS Base LEFT JOIN tqryTasks_Pro_LoanValue AS LoanValue ON (Base.ValueLocation = LoanValue.ValueLocation) AND (Base.LookupValue = LoanValue.FieldName) AND (Base.LoanId_fk = LoanValue.LoanId_pk);
Code:
SELECT Base.LoanId_fk , Base.TaskId_pk , Base.Description , Base.TaskOrder , Base.ValueLocation , LoanValue.FieldName , LoanValue.FieldValue FROM tqryTasks_Pro_Base AS Base LEFT JOIN tqryTasks_Pro_LoanValue AS LoanValue ON (Base.LookupValue = LoanValue.FieldName) AND (Base.LoanId_fk = LoanValue.LoanId_pk);
Comment