I have a dataset that is organized hierarchically, which should be able to grow to an arbitrary size. I need to get the whole tree, but I can’t figure out how to do this using only SQL. My current solution is to create a temporary table and use a recursive function to query the tree branches sequentially, and then save the result in the temporary table, which I will subsequently query again to get the desired result.
My question is what am I doing - is this essentially what the connection is doing right? Build a staging table and then query for results. It seems like there should be a way to do this using joins, but the MySQL documentation only covers extracting parts of the tree to a finite depth. Is there any way to do this? I am doing this in PHP.
source
share