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)
 Help joing 4 tables.

Author  Topic 

Eagle_f90
Constraint Violating Yak Guru

424 Posts

Posted - 2008-03-11 : 09:43:06
I need a bit of help writting a select statment and joining 4 differant talbes. I have used inner joins between two different tables before but never more then two tables.

Table layout (listing only the columns I want to pull):

Abbrevations.Short
Abbrevations.Long

Avatars.Creator
Avatars.AvatarName
Avatars.FileName
Avatars.Game
Avatars.Section
Avatars.Width
Avatars.Height

FanInfo.Crator
FanInfo.ContactMethod
FanInfo.Address

FanRattings.Cration
FanRattings.Rating

How they relate:
Abbrevations.Short = Avatars.Game
Avatars.Creator = FanInfo.Creator
Avatar.AvatarName = Ratings.Cration

Any help would be really helpful. Thanks

--
If I get used to envying others...
Those things about my self I pride will slowly fade away.
-Stellvia

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-03-11 : 09:51:53
SELECT {column list here}
FROM Table1 AS t1
INNER JOIN Table2 AS t2 ON t2.ColX = t1.ColY
INNER JOIN Table3 AS t3 ON t3.ColF = t2.ColZ
INNER JOIN Table4 AS t4 ON t4.ColG = t3.ColE



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-03-11 : 10:00:43
SELECT fields
FROM FanRattings fr
INNER JOIN Avatars a
ON a.AvatarName = fr.Cration
INNER JOIN FanInfo fi
ON fi.Creator = a.Creator
INNER JOIN Abbrevations ab
ON ab.Short=a.Game
Go to Top of Page

Eagle_f90
Constraint Violating Yak Guru

424 Posts

Posted - 2008-03-11 : 10:05:18
Freaking hell, did not realize it was that easy. thanks.

--
If I get used to envying others...
Those things about my self I pride will slowly fade away.
-Stellvia
Go to Top of Page
   

- Advertisement -