having a PARENT-CHILD structure table as follows (product_level can go as high as 6)
i would like to write a script (the more efficient, the better) to create a flat version of it that would look as below:
with some columns having NULL values if the corresponding leaf is non-existent
well... i have written a code too, but i find it too inefficient, and only usable for this case...
if anyone could at least provide me with an algorithm, id really appreciate it
thanks!
Code:
product_id int
product_parent_id int
product_level int
product_name varchar
<some data> <some type>
i would like to write a script (the more efficient, the better) to create a flat version of it that would look as below:
Code:
name1, id1, parent_id1,... nameX, idX, parent_idX .... name6, id6, parent_id6
with some columns having NULL values if the corresponding leaf is non-existent
well... i have written a code too, but i find it too inefficient, and only usable for this case...
if anyone could at least provide me with an algorithm, id really appreciate it
thanks!