Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Dadalushhai
Starting Member
3 Posts |
Posted - 2005-11-23 : 06:55:33
|
| hello,I have an associative table consisting of two columns namely "AId" and "BId". Both these columns are foriegn keys of two distinct other tables. Now, one AId can relate to multiple BIds and vice versa.I am given a particular AId and I can easily get it's corresponding BIds. Now the problem is that I want to have all the AIds that are also related to maximum of those BIds that I just got through that particular AId. Secondly, I want to have all those Bids that are related to the maximum of Aids that i just got above in decending order (most related first).What is the most suitable and efficient way to perform this?for exampleAId BId1 a1 b1 c2 c2 b2 e2 f2 g3 a3 e3 b3 f4 e4 g4 c4 i5 k5 l5 mIf Aid = "1" is the targeted search then resulting Aids should be 2,3 because in "2" {c,b} are present and in "3" {a,b} and "4" {c} respecctively are present secondly the BId that we should recieve are {e,f,g} in descending order because "e" is asociated with maximum of the AIds that we got from above and then "f" and "g" because they are less occuring than "e" and so on....thanks. |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2005-11-23 : 07:39:42
|
| Can you post some sample data ..???Sucess Comes to those who Believe in Beauty of their Dream.. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
Dadalushhai
Starting Member
3 Posts |
Posted - 2005-11-23 : 08:13:01
|
| I dont think so that tree structure would be suitable... How do you propose a tree structure would help in this situation? |
 |
|
|
|
|
|