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

'hasOwnProperty' in javascript -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

How to understand 2 main() functions after using uftrace to profile the C++ program? -