I seek the solution for SQL browse my " SQL tree." I found several topics but I can not fit my problem.
Here is my example:
I have several element A ( ID = 1 ), B ( ID = 2 ), C ( ID = 3 ), D ( ID = 4 ), E ( ID = 5 ), F ( ID = 6 ), G ( ID = 7)
corresponding tree
------------- A ---------
| | |
B C D
|
E
------
| |
F G
I want to receive all ID descend from A ( 1,2,3,4 .. so ) but also to all the IDs from only E (5,6,7 )
I tested several recursive means, without success.
Note that I do not know the leaves which I want to achieve , so I have to necessarily go, the father to the son .
My tables :
'alim' : all letters (Here letters for ex) with an ID
Exemple :
id | letters
__________________
1 | A
2 | B
...
'sous_categ' : which contains the id of the id of A and son
Exemple :
id | id_sc_categ
__________________
1 | 2
1 | 3
1 | 4
Links found : http://explainextended.com/2009/03/17/hierarchical-queries-in-mysql/ http://sqlpro.developpez.com/cours/arborescence/