Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Andal
Starting Member
1 Post |
Posted - 2003-01-30 : 10:45:21
|
| Hi. Can somebody help me with menu tree query? The table structure is (menu_id, parent_id, title)To populate menu tree i use the following query:selectm1.title as m1_title, m2.title as m2_title, m3.title as m3_titlefrom menu m1, menu m2, menu m3where m3.parent_id=*m2.menu_id and m2.parent_id=m1.menu_idI need to get all menu tree (for example just 3 levels as in my query)It is no problem with 2 level menu , but how it will be with more levels (3 or 4)The main problem of query above is:If upper menu level just call it (level1) had no child objects (level2 and level3) the row does not apear in the recordset i need to get the following result, if upper level have no child objects:level1->Null-->Nulllevel1->level2-->Nulllevel1->level2-->level3with the sqlqyery above it is possible to show only the followings:level1->level2-->Nulllevel1->level2-->level3If the tree node like this: level1->Null-->Null the record a not selected. Can you provide any suggestion?I 'll be happy to get any advice from you.And sorry for my english.ThanksEdited by - andal on 01/30/2003 10:46:54 |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2003-01-30 : 10:59:50
|
| http://www.sqlteam.com/item.asp?ItemID=8866That should get you started. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-01-30 : 13:10:39
|
| GREAT Article robvolk. Had to do something similar a while back for DB2 O/s 390. Not as elegant as what you proposed however. The article mention part 2, but I can't locat it, and there is no link to it.Can you help me out?ThanksBrett8-) |
 |
|
|
|
|
|