Is there a way to traverse tree data in SQL? I know about
connect by in Oracle, but is there another way to do this in other SQL implementations? I'm asking because using
connect by is easier than writing a loop or recursive function to run the query for each result.
Since some people seem to be confused by the phrase "tree data" I will explain further: What I mean is with regards to tables which have a
parent_id or similar field which contains a primary key from another row in the same table.
The question comes from an experience where I was working with data stored in this way in an Oracle database and knew that the
connect by isn't implemented in other DBMSs. If one were to use standard SQL, one would have to create a new table alias for each parent one would want to go up. This could easily get out of hand.