I have this table :
create table testtb (c1 number, c2 number);
insert into testtb values (1, 100);
insert into testtb values (2, 100);
insert into testtb values (3, 100);
insert into testtb values (3, 101);
insert into testtb values (4, 101);
insert into testtb values (5, 102);
commit;
I'm struggling to come up with SQL query that would return the following result when where clause is this : "c2=100"
result set:
c1 c2
-- ---
1 100
2 100
3 100
3 101
4 101
The reason result set contains "3,101" is because it's reachable through "3,100". And same for "4,101" : reachable through -> "3,101" -> "3,100".
UPDATE: This table contains identifiers from 2 different data sets after similarity join. So the idea is to allow user to search by any identifier and show all possible matches between two datasets. That is why when user searches for "c2=100" I also want to show "3,101" and "4,101" to show full graph of matches.
Thanks.
CONNECT BY? Is there a limit to the number of levels - presumably at least 2 levels to get the4,101entry. But it isn't very clear quite what you need...