Home > database >  SQL query tree view, not check not children of the parent
SQL query tree view, not check not children of the parent

Time:09-23

Built a view, field ids, parentID, LEAF
The parent node parentID is empty, child nodes parentID is belong to the parent node ID
How to filter out not children of the parent data line,

CodePudding user response:

LEAF field is all child nodes have the same value, the parent node is empty

CodePudding user response:

Select *
The from t_aa1 t
Where t.i d not in
(select Amy polumbo arentid from t_aa1 a where Amy polumbo arentid is not null)
And t.l eaf is null;
Seems the SQL can meet your requirements

CodePudding user response:

refer to the second floor liuzhijian2008x response:
select *
The from t_aa1 t
Where t.i d not in
(select Amy polumbo arentid from t_aa1 a where Amy polumbo arentid is not null)
And t.l eaf is null;
Looks like the SQL can meet the demand of you



Useful, it can detect father no children

CodePudding user response:


Seem to understand the wrong you mean, you are either not children of the parent line, other all query out?
Select * from t_aa1 t where
T.i d in (select Amy polumbo arentid from t_aa1 a)
The or t.l eaf is not null;

CodePudding user response:

reference 4 floor liuzhijian2008x response:
seem to understand the wrong you mean, you're either check no children of the parent bank, other all query out?
Select * from t_aa1 t where
T.i d in (select Amy polumbo arentid from t_aa1 a)
The or t.l eaf is not null;

can

CodePudding user response:

Select *
The from t_aa1
Start with parentid is null
Connect by the prior id=parentid
  • Related