Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

i have two identical table

the first table's structure is like a tree where each record acts like a node.

each node has three field consist of: index as the node-id, item as the represent of item name, parents as pointer to the previous node(index)..

as you can see at the picture each node related to each other based on their parent-index field relation

now what i wanna do is traversing each node(record) to the root, then arrange them into a new table with the same structure, so later on the 2nd table will have 21 records as seen on picture

i'm using vb.net and for next looping to loop the index of each row, then insert each row into a new table.. but the problem is how can i ** copy the data from 1st table to 2nd table with condition parent-child **

here's the picture

enter image description here

i think this case need a recursion method, so in mysql what method should i use to create that? i googled about self join but can't find the right implementation to my problem.

share|improve this question

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.