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)
 Joining Multiple Tables

Author  Topic 

mmor10
Starting Member

2 Posts

Posted - 2004-04-26 : 17:35:34
Is it possible to join more than two tables? I'm looking to join five. If so, I'd greatly appreciate any help with the syntax. Thanks in advance!

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-04-26 : 17:42:03
Yes you can:

SELECT t1.ColumnA, t2.ColumnB, t3.ColumnA, t4.ColumnB, t5.Column1
FROM Table1 t1
INNER JOIN Table2 t2
ON t1.Column1 = t2.Column1
INNER JOIN Table3 t3
ON t2.Column1 = t3.Column1
INNER JOIN Table4 t4
ON t3.Column1 = t2.Column1
INNER JOIN Table5 t5
ON t4.Column1 = t5.Column1

The ON mappings will probably be the PKs and FKs for the tables.

Tara
Go to Top of Page
   

- Advertisement -