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 |
ryanoc
Starting Member
25 Posts |
Posted - 2007-03-07 : 15:35:05
|
I have a table with a parent, child, and grandchild relationship. Can anyone help me with a query that will return the child and grandchild of a parent? Heres a table that I have:id | pid | name----------------3 | 0 | parentcat4 | 3 | childcat5 | 4 | grandchildcatthanks for any help!Ryan |
|
X002548
Not Just a Number
15586 Posts |
|
ryanoc
Starting Member
25 Posts |
Posted - 2007-03-07 : 17:06:53
|
3 | 0 | parentcat4 | 3 | childcat5 | 4 | grandchildcatthere are other records in the table but this is what i need. i want to specify 3 as the id and get all children and grandchildren in a single query.Thanks!Ryan |
 |
|
X002548
Not Just a Number
15586 Posts |
|
ryanoc
Starting Member
25 Posts |
Posted - 2007-03-07 : 17:24:55
|
sql 7. Heres a better display of what Im looking for...Heres my table:id pid name--------------------------------1 0 UntID2 0 Vin Number3 0 Make4 3 Model5 4 Model Number6 0 Model Year7 0 Vehicle Type8 0 Odometer MilesWhen I select 3 as the id I need these results:id pid name--------------------------------3 0 Make4 3 Model5 4 Model Number |
 |
|
|
|
|