View Single Post
Old 03-16-2011, 08:57 PM  
vdbucks
Monger Cash
 
Industry Role:
Join Date: Jul 2010
Posts: 2,773
Quote:
Originally Posted by qw12er View Post
Basicaly I need to fetch the root parent of any object child. (could be as low as 25 level deep into the tree structure.)

Is there a way to do it in mysql ? I've seen it in SQLServer with the "With" statement.

heres my db columns:

dbID idParent idChild
1 2
1 3
2 4
2 5
4 6


For example, I need to query to return 1 if I look for idChild = 6

thanks
Not really sure what you're trying to accomplish as it doesn't appear as though your example matches your explanation.

Are you trying to do something like:

Code:
idParent* = 1
|
---> idChild => 2,3,4,5,6 #so on and so forth
From the sounds of your description, this is what you mean.. but from your example it's not. But then, the example you gave doesn't show how the idChild 6 has the root idParent of 1 to begin with... Unless of course I'm missing something.

All in all, more information is needed.

*I'm not including additional idParent values as of now in order to get an exact idea of what you're trying to accomplish.

Last edited by vdbucks; 03-16-2011 at 08:58 PM..
vdbucks is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote