When LEFT JOINing
tables in a SQL query, sometimes I need to reference multiple tables in the ON
clause. For example:
SELECT p.Name, j.Job, s.Salary
FROM PeopleTable p, JobTable j
LEFT JOIN SalaryTable s ON s.PeopleID=p.PeopleID AND s.JobID=j.JobID
However, the above would give this error:
SQL Error: The multi-part identifier "p.PeopleID" could not be bound.
It seems that the ON
clause in a LEFT JOIN
statement can only "see" the last table listed in the FROM
list. Is this true? Any workarounds?