title: Loading Tree from Database
body: <p>I have some Categories, but some of them have sub-categories. So I have a Tree.</p>
  
  <p>I created a table which called <strong>Categories</strong>. The <strong>id</strong> field is the primary key the other field is <strong>PARENTID</strong>  which is foreign key referenced by the <strong>id</strong> ( To make it hierarchical).  you can have a view of data here</p>
  
  <p><img src="https://i.stack.imgur.com/qK4W8.png" alt="enter image description here"></p>
  
  <p>I am going to specify a certain <strong>id</strong>  and the query gives me the <strong>id</strong>'s of that category <strong>and all sub-categories</strong>. I have red <a href="http://www.codeproject.com/Articles/8355/Trees-in-SQL-databases" rel="nofollow noreferrer">this</a> 
   and <a href="https://stackoverflow.com/questions/13225429/how-do-i-load-hierarchical-data-from-a-database-into-a-tree-view">this one</a> ,but none of them are not useful.</p>
  
  <p><em>one more point: I am not asking you to write the query for me. I am just looking for some hints</em></p>