title: Select all child records against specific id in mysql
body: <p>I have many records in task table with parent_id. 
  Like</p>
  
  <pre><code> task_id name parent
     1      a     0
     2      b     1
     3      c     2
     4      d     3
     5      e     0
     6      f     5
  </code></pre>
  
  <p>I have task_id 1 in my shared table so I want to  select it and its all child record till nth level.
  I have this query</p>
  
  <pre><code>SELECT 
      shared.task_id,tsk.* 
  FROM 
      tbl_sharedtasks shared, tbl_tasks tsk 
  WHERE 
      shared.user_id=1 AND tsk.task_id=shared.task_id.shared 
  </code></pre>
  
  <p>suppose 1</p>
  
  <p>But this select only one record. Problem is that this should select First and task_id 1 have a child record task_id 2 and 2 have 3 parent and 3 have 4 parent. so these all should select all which have relation with parent</p>