I get a “Type mismatch in join expression” error when I try to run below SQL:
SELECT Query5.promotionType, Query5.DirectorCode, Query5.Code, Query5.tempYear, Query5.Month, Query5.ManagerName, NewQuery.Accrual
FROM NewQuery INNER JOIN Query5 ON (NewQuery.tempMonth = Query5.Month) AND (NewQuery.tempYear = Query5.tempYear) AND (NewQuery.Code = Query5.Code) AND (NewQuery.RegionalDirectorCode = Query5.DirectorCode) AND (NewQuery.PromotionType = Query5.promotionType);
Note that Query5 doesn’t display results though. This is the SQL for Query5:
SELECT Query4.promotionType, Query4.DirectorCode, Query4.Code, Query4.tempYear, Query4.Month, Query4.ManagerName
FROM NewQuery LEFT JOIN Query4 ON NewQuery.tempYear = Query4.tempYear
GROUP BY Query4.promotionType, Query4.DirectorCode, Query4.Code, Query4.tempYear, Query4.Month, Query4.ManagerName;
And from the above, you’ll notice references to Query4.tempYear, which is an expression I added to Query4 and have it contain an EMPTY STRING against which, in Query5, I am trying to do a LEFT JOIN from NewQuery.tempYear to Query4.tempYear
And then the error message comes up I mentioned at the start of this post. Any idea why?
SELECT Query5.promotionType, Query5.DirectorCode, Query5.Code, Query5.tempYear, Query5.Month, Query5.ManagerName, NewQuery.Accrual
FROM NewQuery INNER JOIN Query5 ON (NewQuery.tempMonth = Query5.Month) AND (NewQuery.tempYear = Query5.tempYear) AND (NewQuery.Code = Query5.Code) AND (NewQuery.RegionalDirectorCode = Query5.DirectorCode) AND (NewQuery.PromotionType = Query5.promotionType);
Note that Query5 doesn’t display results though. This is the SQL for Query5:
SELECT Query4.promotionType, Query4.DirectorCode, Query4.Code, Query4.tempYear, Query4.Month, Query4.ManagerName
FROM NewQuery LEFT JOIN Query4 ON NewQuery.tempYear = Query4.tempYear
GROUP BY Query4.promotionType, Query4.DirectorCode, Query4.Code, Query4.tempYear, Query4.Month, Query4.ManagerName;
And from the above, you’ll notice references to Query4.tempYear, which is an expression I added to Query4 and have it contain an EMPTY STRING against which, in Query5, I am trying to do a LEFT JOIN from NewQuery.tempYear to Query4.tempYear
And then the error message comes up I mentioned at the start of this post. Any idea why?