oracle - SQL Query to find all possible paths -
i have table :
create table testtb (c1 number, c2 number); insert testtb values (1, 100); insert testtb values (2, 100); insert testtb values (3, 100); insert testtb values (3, 101); insert testtb values (4, 101); insert testtb values (5, 102); commit;
i'm struggling come sql query return following result when clause : "c2=100"
result set:
c1 c2 -- --- 1 100 2 100 3 100 3 101 4 101
the reason result set contains "3,101" because it's reachable through "3,100". , same "4,101" : reachable through -> "3,101" -> "3,100".
update: table contains identifiers 2 different data sets after similarity join. idea allow user search identifier , show possible matches between 2 datasets. why when user searches "c2=100" want show "3,101" , "4,101" show full graph of matches.
thanks.
select distinct c1, c2 testtb connect nocycle prior c1 = c1 or prior c2 = c2 start c2 = 100 order c1, c2;
Comments
Post a Comment