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)
 perhaps need multiple joins

Author  Topic 

zhshqzyc
Posting Yak Master

240 Posts

Posted - 2008-08-05 : 15:53:24
Hello,

I have three tables.

A
S_ID    		 P_ID 		     OBJ_ID
4101670 2692 654860
4493435 14417 654973


B
OBJ_ID            AMT
654860 248
657777 -6


C
S_ID            DEC
4101670 RADIO
1008759 TAPE


I want to get the record as

S_ID            P_ID         OBJ_ID         AMT           DEC
4101670 2692 654860 249 RADIO


Assuming P_ID='2692' known.
Thanks

Vinnie881
Master Smack Fu Yak Hacker

1231 Posts

Posted - 2008-08-05 : 15:55:37
Select * from
a
inner join
b
on a.Obj_ID = b.Obj_ID
Inner JOin
C
on a.S_ID = c.S_ID
Go to Top of Page

MikeZ
Starting Member

6 Posts

Posted - 2008-08-06 : 04:04:13
you can use subquery instead of inner join
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-06 : 04:10:42
quote:

S_ID P_ID OBJ_ID AMT DEC
4101670 2692 654860 2498 RADIO


the AMT should be 248 not 249


quote:
Originally posted by MikeZ

you can use subquery instead of inner join


should use INNER JOIN. It give better performance compare to subquery



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -