maoning 回复 18017687066(提问者)create table temp_quanxian(
userid number(10),
parentid number(10)
);
insert into temp_quanxian
values(\'1\',\'11\');
insert into temp_quanxian
values(\'2\',\'11\');
insert into temp_quanxian
values(\'3\',\'11\');
insert into temp_quanxian
values(\'4\',\'12\');
insert into temp_quanxian
values(\'5\',\'12\');
insert into temp_quanxian
values(\'6\',\'12\');
insert into temp_quanxian
values(\'11\',\'111\');
insert into temp_quanxian
values(\'12\',\'111\');
insert into temp_quanxian
values(\'13\',\'111\');
commit;
select t.userid from temp_quanxian t
where t.userid=\'${userid}\'
union all
select t.userid from temp_quanxian t
where t.parentid=\'${userid}\';