mysql树形查询语句

来源:互联网 发布:linux terminal 命令 编辑:程序博客网 时间:2024/06/06 00:29

select t1.* from tableA t1 where #组
EXISTS (select t2.DIVISION_ID from tableA  t2 where t2.DIVISION_ID=t1.PARENT_ID and #村
EXISTS (select t3.DIVISION_ID from tableA  t3 where t3.DIVISION_ID=t2.PARENT_ID 
and t3.DIVISION_ID='13701FC28AFB4EE9A1758F1BEBF1D5A8')
);


select t1.* from basic_administrative_division t1 where #组

EXISTS (select t2.DIVISION_ID from basic_administrative_division t2 where t2.DIVISION_ID=t1.PARENT_ID and #村
EXISTS (select t3.DIVISION_ID from basic_administrative_division t3 where t3.DIVISION_ID=t2.PARENT_ID 
and t3.DIVISION_ID='13701FC28AFB4EE9A1758F1BEBF1D5A8')
);
原创粉丝点击