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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 complicated query

Author  Topic 

kuba-re
Starting Member

2 Posts

Posted - 2011-01-28 : 05:09:12
I have following tables:

partner
id|name|email| - id is primary key

role_per_partner
partner_id|role_id|module_id|
- partner_id and role_id are complex primary key
- partner_id is foreign key that connects role_per_partner with partner table(one to many relation)
- role_id is foreign key of role table (one to many relation)
- module_id is foreign key of module table

module
id|name|desc|
-id is primary key

modul_task
id|module_id|..
- -id is primary key

Basically, one parter can be responsible for more than one modules and module can have many_task

I need to get all the modules which belong to particular partner knowing only the module_task.id

I know how to find the partner responsible for particular module_task knowing module_task.id but I do not know how to find the other modules which belong to this partner but contain this module_task

I hope you understood .. in case of doubts do not doubt to ask me questions

kuba

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2011-01-28 : 05:27:27
SELECT p.Name, m.Name
FROM dbo.ModuleTask AS mt
INNER JOIN dbo.Module AS m ON m.ID = mt.ModuleID
INNER JOIN dbo.Partner AS p ON p.ID = m.ModuleID
WHERE mt.ID = @YourModuleTaskIdVariableValueHere


N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

kuba-re
Starting Member

2 Posts

Posted - 2011-01-28 : 07:57:07
I managed to solve the issue. embedded the query that you posted in other query and it worked ... thx kuba
Go to Top of Page
   

- Advertisement -