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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Sql Query

Author  Topic 

Moody1
Starting Member

2 Posts

Posted - 2009-10-26 : 17:00:11
Hello,
Ihope to find some help in here, i have the following diagram

[URL=http://img143.imageshack.us/i/13503390.jpg/][/URL]

and i want a query which return Emp_ID, Pro_ID

note;
i can get these values but by 2 queries as the following;
select Pro_ID from Projects where Dep_ID in
(select Dep_ID from Departments where name = 'test')

select Emp_ID from Employees where Dep_ID in

(select Dep_ID from Departments where name = 'test')

the goal of having the result through one query is that i want to insert the value into another table
insert into testTable (query)

Hope to see reply ASAP



Sachin.Nand

2937 Posts

Posted - 2009-10-27 : 09:16:23
insert into testtable
(select P.Pro_ID,E.Emp_ID from Projects P
inner join Departments D on P.Dep_ID=D.Dep_ID
inner join Employees E on E.Dep_ID =D.Dep_ID
where D.name='test')

PBUH
Go to Top of Page

Moody1
Starting Member

2 Posts

Posted - 2009-10-27 : 14:35:10
Hello Idera
Thanks a lot for ur help i've tried it and it works.
Go to Top of Page
   

- Advertisement -