sql - What is B.N in mysql query? -
select n, if(p null,'root',if((select count(*) bst p=b.n)>0,'inner','leaf')) bst b order n;
here n , p column names n node , p parent,bst name of table , above query find node type of bst not able understand what p=b.n mean?
first, let me start saing hope these not actual names using. if are, future self huge favor , replace them readable names describs data columns , tables holds.
that being said, b.n
n
column in row of outer query, since it's using b
alias table name.
in where
clause of sub query, comparing value of p
value of n
main query. subquery run once each row in main query, each row getting count of rows n
parent of node.
Comments
Post a Comment