本人 直接上级 间接上级
A01 B01 C01
本人可以找到直接上级,
直接上级也可以找到间接上级
怎么用本人找到间接上级,要的不是固定一个人,是可以灵活并且很多人。
现用select查询出来,需要用update语句来写出来
select A01 from a where A01 in
(select B01 from a where A01 in
(select B01 from a where a0190='70810001') )
SQL select 实用
------解决方案--------------------
大体应该是这个意思:
select a.本人,b.直接上级
from Employees a left join Employees b on a.直接上级 = b.本人
------解决方案--------------------
要是update语句的话可以这样 update t1 set t1.c1=@value where PK(主键列) in (select 外键列明 from .....)这样可以多个记录同时更新,不知道理解的对不
------解决方案--------------------