KaZzA
KaZzA

Reputation: 104

Multiple joins sql

I have a query which must contain 3 joins, however I get this error:

Syntax error (Missing operator)

The SQL:

SELECT
    Agents.[PF],
    Agents.[User_ID],
    Agents.[First_Name],
    Agents.[Second_Name],
    Agents.[Third_Name],
    Agents.[Family_Name],
    Agents.[Gender],
    Agents.[Contract_Type],
    Agents.Area,
    Teams.Team_Name,
    Agents.Hiring_Date,
    Resignation_Pool.Resignation_Date,
    Resignation_Pool.Effective_Date,
    Replace(
          IIf(Skills.Skill_Directory IS NULL, '', 'Directory, ')
        + IIf(Skills.Skill_TRC IS NULL, '', 'TRC, ')
        + IIf(Skills.Skill_Prepaid IS NULL, '', 'Prepaid, ')
        + IIf(Skills.Skill_Postpaid IS NULL, '', 'Postpaid, ')
        + IIf(Skills.Skill_KeyAccount IS NULL, '', 'KeyAccount, ')
        + IIf(Skills.Skill_Blackberry IS NULL, '', 'Blackberry, ')
        + IIf(Skills.Skill_Broadband IS NULL, '', 'Broadband, ')
        + IIf(Skills.Skill_Concierge IS NULL, '', 'Concierge, ')
        + IIf(Skills.Skill_ISP IS NULL, '', 'ISP, ')
        + IIf(Skills.Skill_Mada IS NULL, '', 'Mada, ')
        + IIf(Skills.Skill_CSCS IS NULL, '', 'CSCS, ')
        + '$', ', $', ''
    ) AS Skills
FROM Agents
LEFT JOIN Resignation_Pool
    ON Agents.PF = Resignation_Pool.PF
LEFT JOIN Teams
    ON Agents.Team = Teams.ID
LEFT JOIN Skills
    ON Agents.PF = Skills.PF
WHERE Agents.Contract_Status = 'Active'

What is causing this error?

Upvotes: 2

Views: 1442

Answers (1)

Taryn
Taryn

Reputation: 247850

MS Access requires parentheses around JOIN syntax with multiple tables. You will need to use something similar to this:

FROM ((Agents
LEFT JOIN Resignation_Pool
    ON Agents.PF = Resignation_Pool.PF)
LEFT JOIN Teams
    ON Agents.Team = Teams.ID)
LEFT JOIN Skills
    ON Agents.PF = Skills.PF

Upvotes: 5

Related Questions