I have a table that looks like this where I need previous id until refid is NULL.My table looks like this:---------------------------------| id | refid | Title |---------------------------------| 1 | NULL | Group1 || 2 | NULL | Group2 || 3 | 1 | Undergroup1 || 4 | 1 | Undergroup2 || 6 | NULL | Group3 || 7 | 3 | Underundergroup1 || 8 | 3 | Underundergroup2 || 9 | NULL | Group3 || 11 | NULL | Group3 |---------------------------------
Now if I choose ID 7, my resultset should be: ---------------------------------| id | refid | Title |---------------------------------| 1 | NULL | Gruppe1 || 3 | 1 | Undergruppe1 || 7 | 3 | Underundergruppe1|---------------------------------
if I choose ID 3, my resultset should be: ---------------------------------| id | refid | Title |---------------------------------| 1 | NULL | Gruppe1 || 3 | 1 | Undergruppe1 |---------------------------------
How can this be done? I'm a bit stuck here.../Niras