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 |
|
cyberpd
Yak Posting Veteran
60 Posts |
Posted - 2009-07-07 : 06:38:15
|
| hii need a little help in a query.let me explain the situation first.My table has the following fields. 1. mag_agentid (int)2. mag_parentorig (int)3. mag_parentdisplay (int)4. mag_parentleg (nvarchar 10)5. mag_firstname (nvarhcar 100)Hierarchical data is represented in the table (mst_agent).The guy at the root will have mst_parentorig =0, mst_parentdisplay = null, suppose his name is RI, mag_agentid = 1He has got two childs CH (left child) and PA (right child)CH has mag_parentdisplay = 1(equal to mag_agentid of root, RI) and mag_parentorig = 1, mag_agentid = 2, mag_parentleg = 'L'CH has two childs SA (left child) and KA (right child)SA has mag_parentorig = 1, mag_parentdisplay = 2(equal to mag_agentid of CH), mag_agentid = 3, mag_parentleg = 'L'KA has mag_parentorig = 1, mag_parentdisplay = 2(equal to mag_agentid of CH), mag_agentid = 4, mag_parentleg = 'R'I want to find out all the mag_agentid who are in the left hand side of the root.In this case, the result will return mag_agentid = 2, 3, 4 and so on. |
|
|
waterduck
Aged Yak Warrior
982 Posts |
Posted - 2009-07-07 : 08:52:27
|
| http://blogs.conchango.com/christianwade/archive/2004/11/09/234.aspxhope this can help youAMITOFO+AMEN+YA ALLAH Hope the query works |
 |
|
|
|
|
|
|
|