The below join works in Access, but I need to add a fourth join.
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
When I add the fourth join, it doesn't work. I know Access is weird about the parenthesis, but I think I have them where they belong. The query just runs forever doing nothing (it shouldn't run long at all) and I end up cancelling it. Any suggestions?
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)
LEFT JOIN OneMore ON Agents.OM = OneMore.OM
Here is the code that works - my actual query instead of one I found that looked similar.
SELECT DISTINCT A02.PID, A02.PS, A02.PN, A02.PM, C01.RC, C01.IC, C01.RD
INTO AutoCR
FROM ((02_CorrectResults A02
LEFT OUTER JOIN dbo_pol_PGI C01
ON (A02.PID = C01.PID and C01.PS = '999' and C01.PEDate >= #04/01/2012#))
LEFT OUTER JOIN dbo_pol_IL C02
ON C01.PID = C02.PID)
LEFT OUTER JOIN dbo_pol_UN C03
ON C02.ILID = C03.ILID
I add another join and this doesn't work. I tried using inner join instead but Access doesn't like that.
SELECT DISTINCT A02.PID
, A02.PS
, A02.PN
, A02.PM
, C01.RC
, C01.IC
, C01.RD
, C04.CCode
, C04.PCode
, C04.CForm,
INTO AutoCR
FROM (((02_CorrectResults A02
LEFT OUTER JOIN dbo_rol_PGI C01
ON (A02.PID = C01.PID and C01.PS = '999' and C01.PEDate >= #04/01/2012#))
LEFT OUTER JOIN dbo_rol_IL C02
ON C01.PID = C02.PID)
LEFT OUTER JOIN dbo_rol_UN C03
ON C02.ILID = C03.ILID)
LEFT OUTER JOIN dbo_rol_HO C04
ON C03.UnID = C04.UnID
Here when it comes to Left Join in SQL it only returns all the records or tuples or rows from left table and only those records matching from the right table. Syntax For Left Join: SELECT column names FROM table1 LEFT JOIN table2 ON table1.
Yes, indeed! You can use multiple LEFT JOINs in one query if needed for your analysis.
Use a LEFT JOIN operation to create a left outer join. Left outer joins include all of the records from the first (left) of two tables, even if there are no matching values for records in the second (right) table. Use a RIGHT JOIN operation to create a right outer join.
IS LEFT join slower than join? The LEFT JOIN query is slower than the INNER JOIN query because it's doing more work.
You have a trailing ,
in your query. Remove it.
SELECT DISTINCT A02.PID
, A02.PS
, A02.PN
, A02.PM
, C01.RC
, C01.IC
, C01.RD
, C04.CCode
, C04.PCode
, C04.CForm, <--- this was the problem
INTO AutoCR
FROM (((02_CorrectResults A02
LEFT OUTER JOIN dbo_rol_PGI C01
ON (A02.PID = C01.PID and C01.PS = '999' and C01.PEDate >= #04/01/2012#))
LEFT OUTER JOIN dbo_rol_IL C02
ON C01.PID = C02.PID)
LEFT OUTER JOIN dbo_rol_UN C03
ON C02.ILID = C03.ILID)
LEFT OUTER JOIN dbo_rol_HO C04
ON C03.UnID = C04.UnID
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With