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)
 HOW TO CREATE JOIN BETWEEN 5 OR MORE TABLES

Author  Topic 

neellotus
Starting Member

15 Posts

Posted - 2013-02-20 : 09:48:41
Hi All,

I have fine tables table1,table2,table3,table4 & table5 and column "code" is contain all tables.
Now i want to create inner join between first three 1, 2 & 3 table.

Then i want inner join between two 4 & 5 table and then i want to create left outer join with first three tables on last two tables.

Pls tell me how to write sql query i will be very thankful to you.

Thanx

Neel

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-02-20 : 10:09:20
[code]
select columns
from table1 t1
join table2 t2
on t2.code = t1.code
join table3 t3
on t3.code = t2.code
left join (select t4.code,.. other columns here
from table4 t4
join table5 t5
on t5.code = t4.code
)t
on t.code = t1.code
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -