select b.* from dict_organ_info a, dict_organ_info b
where
a.organ_id(+) = b.higher_organ
and b.district_belong like '222404%'
and nvl(a.district_belong,'XXX') not like '222404%'
a表是上级部门 b表是本部门
左连接, a.organ_id(+) = b.higher_organ 如果表a中没有相当应的记录则显示空行
and b.district_belong like '222404%' 过滤一下, 只要本部门为222404及其下属的
and nvl(a.district_belong,'XXX') not like '222404%' 过滤掉 上级部门也是在222404下面的
123
where
a.organ_id(+) = b.higher_organ
and b.district_belong like '222404%'
and nvl(a.district_belong,'XXX') not like '222404%'
a表是上级部门 b表是本部门
左连接, a.organ_id(+) = b.higher_organ 如果表a中没有相当应的记录则显示空行
and b.district_belong like '222404%' 过滤一下, 只要本部门为222404及其下属的
and nvl(a.district_belong,'XXX') not like '222404%' 过滤掉 上级部门也是在222404下面的
123