Update a table with the value of the same row
<p>I have a table like this</p>

<pre><code>id     Name   Parent_id   Text
1        x      0         
2        y      1         
3        Z      1        
4        A      2         
5        B      0         
</code></pre>

<p>Now i'd like to populate the column with the text of the column name depending on parent_id. If parent_id is 0 text value will be the name of the same row instead id parent_id!=0 it must find the right name</p>

<p>this is the output I'd like to archieve</p>

<pre><code>id     Name   Parent_id   Text
1        x      0         x
2        y      1         x
3        z      1         x
4        a      2         y
5        b      0         b
</code></pre>

<p>Could someone help me?</p>