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 |
|
WAK
Starting Member
2 Posts |
Posted - 2005-12-09 : 00:40:50
|
SQL Gurus please help.I have following table:+-------------+----------------------+--------+| category_id | name | parent |+-------------+----------------------+--------+| 1 | ELECTRONICS | NULL || 2 | TELEVISIONS | 1 || 3 | TUBE | 2 || 4 | LCD | 2 || 5 | PLASMA | 2 || 6 | PORTABLE ELECTRONICS | 1 || 7 | MP3 PLAYERS | 6 || 8 | FLASH | 7 || 9 | CD PLAYERS | 6 || 10 | Single CD | 9 || 11 | 3 CD Changer | 9 || 12 | 5 CD Changer | 9 || 13 | 2 WAY RADIOS | 6 |+-------------+----------------------+--------+I want to retrieve the leaf nodes of a trunk from this data. I know to retrieve all the leaf nodes I can write a query i.e SELECT t1.name FROMcategory AS t1 LEFT JOIN category as t2ON t1.category_id = t2.parentWHERE t2.category_id IS NULL;But I am interested to get the leaf nodes of a particular branch/trunk node e.g Portable ElectronicsThanks in advance. I hope prompt replyWAK |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|