MySQL: Find top/ultimate parent
问题 I've found a few things similar but nothing quite what I need. ID | PARENT 1 | NULL 2 | 5 3 | 6 4 | 6 5 | NULL 6 | 9 7 | NULL 8 | 7 9 | 8 10 | NULL I have a table that looks like the below and need to find the top-most parent using MySQL. The trouble I'm having in this is that there could be up to 20 in the heirarchy steps to get to the top parent and I think I'm just not well versed enough in MySQL to figure it out. Thanks in advance! 回答1: Here is an answer from me. Its not nice, but it