sql多表连接问题
一共有三张表 1请假表 tblleave中有字段 leaveid employeeid approverid
2员工表 tblemployee 中有字段employeeid loginname deptid
3部门表 departmentid 和name
如何显示 员工名 审批者名 部门名
------解决方案--------------------select a.员工名, d.员工名 as 审批者名, b.部门名
from 员工表 a
left join 部门表 b on (b.departmentid = a.deptid)
left join 请假表 c on (a.employeeid = c.employeeid)
left join 员工表 d on (c.approverid = d.employeeid)
------解决方案--------------------select 员工名 审批者名 部门名 from tblleave a,tblemployee b,department c where a.employeeid =b.employeeid and b.deptid =c.departmentid