I have a table like below
MyTable
| ID | PARENT_ID |
-----------------------------
| 20 | null |
| 40 | null |
| 50 | null |
| 70 | 122 |
| 100 | 40 |
| 102 | 4 |
| 126 | 100 |
| 9 | 50 |
| 122 | 40 |
| 123 | 9 |
I want to select hierarchy tree including all children and parent like below for the given three children 126 ,70 and 123
Expected output
| ID | PARENT_ID |
-----------------------------
| 126 | 100 |
| 100 | 40 |
| 40 | null |
| 70 | 122 |
| 122 | 40 |
| 123 | 9 |
| 9 | 50 |
| 50 | null |
I have tried
select ID, PARENT_ID
from MyTable
start with ID=126 //this for example
connect by prior ID=Parent;