title: Show the data based on Hierarchy [ Grand Parent -> Parent -> Child ]
body: <p>Hi I want to show data as Hierarchy way like this as show in below image</p>
  <p><a href="https://i.stack.imgur.com/2ThXy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2ThXy.png" alt="enter image description here" /></a></p>
  <p>and here is my database table structure</p>
  <p><a href="https://i.stack.imgur.com/ybihL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ybihL.png" alt="enter image description here" /></a></p>
  <p>and here is the query i have used but its not the perfect result i want</p>
  <pre><code>SELECT 
  
  t1.parent_id AS primary_Id,
  t2.parent_id AS secondary_Id,
  t3.parent_id AS teritiary_Id
  
  FROM ucode AS t1
  LEFT JOIN ucode AS t2 ON t2.parent_id = t1.id
  LEFT JOIN ucode AS t3 ON t3.parent_id = t2.parent_id
  </code></pre>
  <p>and the output is</p>
  <p><a href="https://i.stack.imgur.com/8AtwI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8AtwI.png" alt="enter image description here" /></a></p>
  <p>this is not i need</p>
  <p>and one more way i tried</p>
  <pre><code>SELECT 
      
      t1.parent_id AS primary_Id,
      t2.parent_id AS secondary_Id,
      t3.parent_id AS teritiary_Id
      
      FROM ucode AS t1
      LEFT JOIN ucode AS t2 ON t2.parent_id = t1.id
      LEFT JOIN ucode AS t3 ON t3.parent_id = t2.id
  </code></pre>
  <p>and the output is</p>
  <p><a href="https://i.stack.imgur.com/QWSSj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QWSSj.png" alt="enter image description here" /></a></p>
  <h2>can you give me the proper solution for this..</h2>