Posted By

antleung on 11/30/10


Tagged


Versions (?)

Get Tree


 / Published in: MySQL
 

  1. SELECT t1.title AS lev1, t2.title AS lev2, t3.title AS lev3, t4.title AS lev4
  2. FROM tablename AS t1
  3. LEFT JOIN tablename AS t2 ON t2.parent = t1.id
  4. LEFT JOIN tablename AS t3 ON t3.parent = t2.id
  5. LEFT JOIN tablename AS t4 ON t4.parent = t3.id
  6. WHERE t1.title = 'title name';

Report this snippet  

You need to login to post a comment.