If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
You'll probably need to pick a programming language, and then write the recursive code to do what you've described. I don't know of any feature in MySQL that will do that for you.
It would probably be better if you asked your teacher for help. They know what you've covered in class, what criteria they'll use for grading, and your programming environment than I do. Because of that knowledge, they can give you a much better answer than I can.