Recursive query [message #643140] |
Wed, 30 September 2015 03:46 |
|
vasudevaviswa
Messages: 53 Registered: August 2015 Location: US
|
Member |
|
|
Hi All,
Please find here.
A1, , B2, C3are PARENTS.
A1 has Children i.e D4, E5
D4 has GrandChildren i.e F6,G7
E5 has Grand Children i.eH8
I have existed data asfollows.
ID Name
-------------------
| a1 | 1 |
| b2 | 2 |
| c3 | 3 |
| a1.d4 | 4 |
| a1.e5 | 5 |
| a1.d4.f6 | 6 |
| a1.d4.g7 | 7 |
| a1.e5.h8 | 8 |
| a2.i9 | 9 |
| a2.i9.j10| 10 |
etc..
etc...
Now I would like to write a query to retrieve Parent levels for
Required O/P :
| Name | ID | PARENT_ID |
-----------------------------
| a1 | 1 | null |
| b2 | 2 | null |
| c3 | 3 | null |
| a1.d4 | 4 | 1 |
| a1.e5 | 5 | 1 |
| a1.d4.f6 | 6 | 4 |
| a1.d4.g7 | 7 | 4 |
| a1.e5.h8 | 8 | 5 |
| a2.i9 | 9 | 2 |
| a2.i9.j10| 10 | 9 |
...
...
I have here around 500k data..
Can anyone advise query forDynamic data.
Thanks,
Vasudev
Lalit : Corrected code tags
[Updated on: Wed, 30 September 2015 04:28] by Moderator Report message to a moderator
|
|
|
|