In my SQL-database 'exampledb' I've got a table called 'node' created using: (MySQL specific data included)
This table holds id's of nodes as well as the id of their parent node. For example this tree (nodes represented by the id numbers):
Is represented in the node table as
This creates implicit single linked lists from each node through its ancestors up to the root node:
To begin with I need to create an SQL query which takes a node id, and outputs all rows from that node up to and ending with the root node. What would you think is the best way? If it's possible using a single SQL query that would be best. I'm still pretty new to SQL.
[ April 25, 2008: Message edited by: Kent Larsson ]