Please help with SQL combination of INNER JOIN AND LEFT JOIN
Posted on 2004-08-19
I have an sql combination of INNER JOIN AND LEFT JOIN. I did it in MS Access and tried to put it in my <cfquery>
Can someone please help me write this sql correctly:
SELECT tcur.CURoleid, tcur.CURolefunc, tcus.CUserID, tcus.CUlast, tcus.CUfirst,
tcus.CUMI, tcus.CUContact, tcus.CUEmail, tcus.CUDeptID, tcus.CURoleid, tcud.CUDeptID,
tcud.CUDeptNm FROM tCUserRole tcur INNER JOIN (tCUDept tcud LEFT JOIN tCUsers tcus ON tcud.CUDeptID = tcus.CUDeptID) ON tcur.CURoleid = tcus.CURoleid
the left join is neccesary because i would like to get the DeptNm. Not all users might belong to a department so if i don't use left outer join, I will not be able to get the users that does not belong to a department.