SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 HOW TO CREATE JOIN BETWEEN 5 OR MORE TABLES
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

neellotus
Starting Member

India
14 Posts

Posted - 02/20/2013 :  09:48:41  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 02/20/2013 :  10:09:20  Show Profile  Reply with Quote

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


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

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.12 seconds. Powered By: Snitz Forums 2000