Hi friends,
My question is not related to
JDBC but SQL.
I have dependency table as follows.
Now I want to get all unique values from ColumnA and ColumnB for dependencies.
Let us say user wants dependency for A1.
here
so now I have to find dependency for B1.
(I already have dependency for A1 so exclude from this result).
Now I have to find dependency for A2,A3,A4 (unique)...
unique values from above output ----- A2,A3,A4,B1,B2 (B1 is already included in second step of output)...
so again till now unique dependencies are.....
A1(search term),A2,A3,A4,B1,B2
remaining from above is B2, so for B2 now dependency is as below...
A2,A4,A5,A6 (I have to exclude A2,A4 as it has already been part of the search )
so for A5,A6
so final dependencies are A1,A2,A3,A4,b1,B2,B3.
How can I implement this logic in any SQL.
I have some experience in SQL Server stored procedure.
I think cursor, temporary table features can be used in this scenario as.
If you guys have any other solution/suggestion then please guide. I do not want ready made code but some initial steps so I can do it myself.
Thanks for any help.