I have the following table structure:
ORGANIZATION_ID | Name | PARENT_ID
--------------------------------------------------
1 | A | 0 -Indicates root
2 | B | 1
3 | C | 2
4 | D | 2
5 | E | 4
6 | F | 1
7 | G | 1
8 | H | 7
9 | J | 8
10 | K | 9
I am not that great at writing Oracle SQL queries. How can I generate a list of everything (*) child organisation if I pass in a certain Organization ID?
For instance, if I passed in 2, logically I would look for all rows who had a parent ID of 2, then I would recursively look through each of those rows doing the same thing.
I know the logic, how can I recreate that using a sql query in oracle?
CONNECT BYcan be used to make this recursive query: