```
ENTRY TABLE
 __________________
| ID |  PARENT_ID  |
| 1  |    null     |
| 2  |     1       |
| 3  |     2       |
| 4  |    null     |
| 5  |     4       |
| 6  |     5       |
...

```

I make copies of the entries in some cases and they are conneted by parent ID.

Each entry can have one copy:

```
THIS WONT HAPPEN
 __________________
| ID |  PARENT_ID  |
| 1  |    null     |
| 2  |     1       |
| 3  |     1       |
...

```

Sometimes I need to take a copy and query for it's top level parent. I need to find the top parent entries for all the entries I search for.

For example, if I query for the parents of ID 6 and 3, I would get ID 4 and 1.
If I query for the parents of ID 5 and 2, I would get ID 4 and 1.
But also If I query for ID 5 and 1, it should return ID 4 and 1 because the entry ID 1 is already the top parent itself.

I don't know where to begin since I don't know how to recursively query in such case.

Can anyone point me in the right direction?

I know that the query below will just return the child elemements (ID 6 and 3), but I don't know where to go from here honestly.

I am using OracleSQL by the way.

```
SELECT * FROM entry WHERE id IN (6, 3);

```