Let's say that I have the following table
Row_ID | SourceId | TargetId
---------|----------|----------
1 | 1 | 2
2 | 2 | 3
3 | 2 | 4
4 | 4 | 5
5 | 5 | 6
6 | 6 | 5
I have to bring all of these rows in my query because they are all connected. However, when I do this:
SELECT Row_ID
FROM MyTable
START WITH SourceId = 1
CONNECT BY NOCYCLE PRIOR TargetId = SourceId
It will not bring the row with Row_ID equals to 6.
I think it is because of the NOCYCLE
keyword. But if I take it off, the query does not work since there is a cycle there.
I wanted to set a query that would bring me everything. Do you guys have any idea?