0

I am trying to create a relationship between two tables based on multiple fields. In Excel, I would use concatenate to combine the field names into one unique value to do my vlookup. For example, I would lookup City and Department using a combined CityDepartment. How can I make this link similarly in Access tables? If I create a relationship just between City and just between Department I do not get that unique CityDepartment.

If I wanted to do a JOIN on multiple fields...why wouldn't something like this work? I am getting a syntax error.

SELECT HRBI.ID (For all fields)
FROM HRBI 
LEFT JOIN MINC
ON HRBI.PayGroupRegionCode = MINC.Region AND HRBI.PayGroupCountryDesc = MINC.Country AND HRBI.[BusinessLvl1(Group)Code] = MINC.BusinessGroup;
Chris2015
  • 1,030
  • 7
  • 28
  • 42

1 Answers1

0

I was able to combine the two fields by creating the relationships in Design View. I then created a query and edited the SQL to the following:

  SELECT HRBI.PayGroupCountryDesc, HRBI.[BusinessLvl1(Group)Code], MINC.Country, MINC.BusinessGroup, MINC.MINCPercentageofSalary
    FROM HRBI LEFT JOIN MINC ON (HRBI.[BusinessLvl1(Group)Code] = MINC.BusinessGroup) AND (HRBI.[PayGroupCountryDesc] = MINC.[Country])
    ORDER BY HRBI.PayGroupCountryDesc;

No issues after that.

Chris2015
  • 1,030
  • 7
  • 28
  • 42