如何在sql语句中实现递归查询?
文东win 2004-04-08 04:40:15 我有两张表:
人员表man:
mancode //人员编码
manname //人员姓名
deptcode //所属部门编码
部门表dept:
deptcode //部门编码
deptname //部门名称
parentdeptcode //上级部门编码
在dept表中通过parentdeptcode(上级部门编码)实现单位的所属关系和层次划分,
假设有部门的层次如下:
部门a
部门a1
部门a11
部门a12
部门a13
部门a2
部门a21
部门a211
部门a22
部门a23
部门b
我现在想查询部门a中的所有人员如何在一个sql语句中查出来?