title: mysql query to get the root parent
body: <p>I have the following data in table <code>categories</code>:</p>
  
  <pre><code> id  parent_id    title
   -----------------|-------------------
   1         0      |A
   2         1      |B
   3         2      |C
   4         3      |D
   5         4      |E
  </code></pre>
  
  <p>Now I want to get the root category title(parent_id 0) for category id 4 and that is category id 1 of title A.</p>
  
  <p>How can I achieve the required result in a single mysql query? I assume procedural query will be used but I dont know how to do it.</p>