Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
HiSuppose I have a table 'A' with contains different foreign keysTableAID1,ID2,ID3,ID4TableBID2TableCID4TableDID4Now 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 t1INNER JOIN TableB t2 ON t1.ID2 = t2.ID2INNER JOIN TableC t3 ON t1.ID3 = t3.ID3INNER JOIN TableD t4 ON t1.ID4 = t4.ID4WHERE...Is that what you are looking for?Tara
AsimKhaliq
Yak Posting Veteran
94 Posts
Posted - 2003-11-06 : 16:20:24
Yes Thanks
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.ID2UNION 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....Brett8-)
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