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)
 Join Syntex

Author  Topic 

AsimKhaliq
Yak Posting Veteran

94 Posts

Posted - 2003-11-06 : 16:16:56
Hi
Suppose I have a table 'A' with contains different foreign keys
TableA
ID1,ID2,ID3,ID4
TableB
ID2
TableC
ID4
TableD
ID4
Now I like to join Table 'A' to table B ,C and D with their ID, ca any one write me a join statement for this.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-11-06 : 16:18:49
SELECT Column1...
FROM TableA t1
INNER JOIN TableB t2 ON t1.ID2 = t2.ID2
INNER JOIN TableC t3 ON t1.ID3 = t3.ID3
INNER JOIN TableD t4 ON t1.ID4 = t4.ID4
WHERE...

Is that what you are looking for?

Tara
Go to Top of Page

AsimKhaliq
Yak Posting Veteran

94 Posts

Posted - 2003-11-06 : 16:20:24
Yes Thanks
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2003-11-06 : 16:25:34
I'm thinking...


SELECT 'QUERY1' AS Source, a.ID1, a.ID2, a.ID3, a.ID4
FROM TableA a INNER JOIN TableB b ON a.ID2 = b.ID2
UNION ALL
SELECT 'QUERY2' AS Source, Null AS ID1, Null As ID2, Null As ID3, c.ID4
FROM TableC c INNER JOIN TableD d ON c.ID4 =d.ID4


There's got to me more though....



Brett

8-)
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-11-06 : 16:30:08
Yeah, we would need to see sample data and expected result set to determine what the query should look like.

Tara
Go to Top of Page
   

- Advertisement -