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)
 select statement prob

Author  Topic 

niravg
Starting Member

17 Posts

Posted - 2005-01-03 : 11:36:18
hi all:

I have two tables

activity(pk_activity_id,fk_assigned_to,fk_owner,...)
contact(pk_contact_id,last_name)

Both "fk_assigned_to" and "fk_owner" refers to "pk_contact_id"

how do i write a select statement which returns all pk_activity_id, last_name for fk_assigned_to and last_name for fk_owner

any help?

thanks

-Nirav

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-01-03 : 11:47:57
something like this?

select t1.pk_activity_id, t2.last_name, t3.last_name
from activity t1
inner join contact t2 on (t1.pk_activity_id = t2.pk_contact_id)
inner join contact t3 on (t1.fk_assigned_to = t3.pk_contact_id)


Go with the flow & have fun! Else fight the flow
Go to Top of Page
   

- Advertisement -