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 |
|
bharath2020
Starting Member
1 Post |
Posted - 2007-04-14 : 09:33:31
|
| I have a single table named PROCESS which contain following three fieldsProcessID ParentID,info* Every process have a unique ProcessID and ave single parent process which is identified by ParentID. * If a process does not have a Parent then its ParentID value is -1.*Only single level of Parent-child hierarchy is maintained.Can anyone please tell me the Query that uses Recursive JOINS to retrieve the ProcessID s based in following Conditions.1. if the Parent's 'info' field contains given value then retrieve all the process under it.2. Retrive all the process whose 'info' contains given value and excluding the Processes resulted from 1st conditiionThanks in advanceBharath Booshan L |
|
|
blindman
Master Smack Fu Yak Hacker
2365 Posts |
Posted - 2007-04-14 : 23:08:05
|
| If only a single level of Parent-child hierarchy is maintained, then there is no need to use recursive SQL.If more than a single level of Parent-child hierarchy is maintained, then you should use a WHILE loop with a temporary table rather than recursive SQL.If you want help with your homework, you should post your attempt at answering the question first.e4 d5 xd5 Nf6 |
 |
|
|
MutantNinjaLoungeSinger
Starting Member
14 Posts |
Posted - 2007-04-16 : 14:58:55
|
| If you're using SQL 2005, you can also utilize Common Table Expressions to do recursion.However, if you're not, you'll not have much choice but to go with blindman's advice. |
 |
|
|
|
|
|