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

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -