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 2000 Forums
 Transact-SQL (2000)
 query

Author  Topic 

harshal_in
Aged Yak Warrior

633 Posts

Posted - 2003-07-17 : 03:25:46
here is the table structure
table A
user_id user_name
1 harshal
2 jay
3 raj


table B
Project_id Project_name ProjAdded_by ProjectLeader
1 ProjA 1 2
2 projB 2 2
3 ProjC 1 3

here in the table B ,columns projAdded_by and projectleader are the user_id from the table A
I want the names of the person for each product in a single query ,the result should be like

Projectname project_addedby projectleader
ProjA harshal jay
projB jay jay
projC harshal raj


Is this possible with a single query?


regards,
harshal.

The Judgement of the Judge is as good as the Judge.

Andraax
Aged Yak Warrior

790 Posts

Posted - 2003-07-17 : 04:11:05
Hi Harshal!

select b.ProjectName,
a1.user_name as project_addedby,
a2.user_name as projectleader
from a a1,
a a2,
b
where a1.user_id=b.ProjAdded_by and
a2.user_id=b.ProjectLeader


Go to Top of Page

harshal_in
Aged Yak Warrior

633 Posts

Posted - 2003-07-17 : 05:22:56
thanks a lot Andraax.
i think i am growing dumb and dumb day by day!

The Judgement of the Judge is as good as the Judge.
Go to Top of Page

Andraax
Aged Yak Warrior

790 Posts

Posted - 2003-07-17 : 07:29:32
I'm growing lazy... Not good either

Go to Top of Page
   

- Advertisement -