1

I have 3 postgresql tables as follows

employees

emp_name | emp_id | user_name | psw | etc

work

Work_id |work_type| Project_manger_id(employee) | Architect_id (emp) | tech_lead_id | dept_id

dept

dept_id | dept_name 

now what I want is a table like this

work_type | project_manager (name)  | architect (name) | tech_lead (name ) | dept (name )

Simply, what I want is to get the work table but replacing id's with names

4

1 に答える 1

3

これを試して

Select WT.Work_Type,PM.emp_name As ProjectManager,AR.emp_name AS Arhitect,TL.emp_name As  TechLead,Dept.Dept_name As Department From
Work 
INNER JOIN employees AS PM ON (Wt.Project_manger_id=PM.emp_id)
INNER JOIN employees AS AR ON (Wt.Architect_id=AR.emp_id)
INNER JOIN employees AS TL ON (Wt.tech_lead_id=TL.emp_id)
INNER JOIN Dept As Dept ON (Wt.dept_id=Dept.dept_id)
于 2012-05-28T05:06:23.190 に答える