the purpose is to retrieve the whole tree from adjacent-list table with depth as an parameter.SELECT t1.name AS lev1,t2.name AS lev2,t3.name AS lev3 FROM tab AS t1 LEFT JOIN tab AS t2 ON t2.parentID = t1.ID LEFT JOIN tab AS t3 ON t3.parentID = t2.ID WHERE t1.parentID = 0
In reply to generate self join sql with specified depth level by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |