SQL Dameng database parent-child table (tree table) query all subsets, parent
Look at the table first.
In the figure, dic_id is the child key parent_dic_id is the parent key, that is, dic_ic = parent_dic_id
Now to find out all the subsets whose parent id is 1
The sql corresponds to:
some are shown below 内联代码片
.
select * from T_SYS_DIC
start with dic_id = '1000076' CONNECT BY PRIOR dic_id = parent_dic_id
Corresponding results: It can be seen that all the data are subsets whose parent id is 1000076.
Note: PRIOR usage , put before the child id to find the data, all the subsets under the child id
are placed before the parent id to find the data for the parent id See the effect on all parents
results:
This data is learning and testing data. If necessary, please change it to your own corresponding business data. Welcome to advise!