------解决方案-------------------- select 查找字段 from employee e inner join department d on e.deptid=p.deptid ,email,managername,manageremail这些在哪个表呀,就是关联查询
------解决方案-------------------- 就是两表关联查询 通过deptid关联
如果department.managerid来自表employee.employeeid的话
create view view_employee
as
select a.employeeid,a.name,a.email,b.name as managername ,b.email as manageremail
from employee a left join department d on a.deptid = d.deptid
left join employee b on d.managerid = b.employeeid
------解决方案--------------------
SQL code
CREATE VIEW dbo.view_employee_department
AS
select employeeid,name,email
from employee
UNION
select name as managename,email as manegeemail
from employee a left join department b on a.deptid=b.deptid
------解决方案--------------------