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 |
|
slen
Starting Member
2 Posts |
Posted - 2009-08-26 : 23:35:12
|
| I am having a problem to query the proper data ...my table looks like this :------------------id | name | parentid 1 Jane 02 BOB 13 Sharon 24 Karen 15 Tippy 2--------------How do I write a SQL that can query all the children from the parent ...example, I pass in parent id 0 ...and Bob, karen will be queried as wellThanks |
|
|
Nageswar9
Aged Yak Warrior
600 Posts |
Posted - 2009-08-27 : 00:05:09
|
| Hi, try this onceDECLARE @ParentID int,@id INTselect @parentID = 0select @id = id from urtable where parentid = @parentID select * from urtable where parentid = @id |
 |
|
|
slen
Starting Member
2 Posts |
Posted - 2009-08-27 : 02:40:42
|
| Thanks for the reply. It didn't work... It didn't display all the records I want although it did display the child. (it didn't include the parent) ...??I need a child and parent list together ...Thanks |
 |
|
|
|
|
|