안녕하세요 초보 dba입니다



데이터가 아래와 같이있습니다

prarent가 null인것은 부모데이터이구 데이터가있는것은 부모의ID를따라가는 자식데이터입니다


ID     / PARENT   /    second

1           null                    1        

2            1                       2          

3            1                       1

4           null                    2

5           null                    3

6            5                       1

7            5                       3

8            5                       2

9           null                    4

10          9                       1


아래와같이 select를 하고싶은데 쉽지가 않네요

도움을 부탁드립니다


ID     / PARENT   /    second

1           null                    1   

3            1                       1

2            1                       2  

4           null                    2

5           null                    3

6            5                       1

8            5                       2

7            5                       3

9           null                    4

10          9                       1