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
 General SQL Server Forums
 New to SQL Server Programming
 inner join for more than 2 tables

Author  Topic 

asuk1984
Starting Member

1 Post

Posted - 2008-04-09 : 21:01:42
sorry for the noob question.
anyone know how to use inner join, left join or right join to join more than 2 tables? e.g. 3 tables
Thanks in advanced

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2008-04-09 : 21:06:29
select *
from table1 t1
join table2 t2 on t1.col=t2.col
join table3 t3 on t2.asdf=t3.asdf
join table4 t4 on t4.asdf=t3.asdf
...

etc


elsasoft.org
Go to Top of Page

Sharama
Starting Member

1 Post

Posted - 2009-04-08 : 15:29:10
quote:
Originally posted by jezemine

select *
from table1 t1
join table2 t2 on t1.col=t2.col
join table3 t3 on t2.asdf=t3.asdf
join table4 t4 on t4.asdf=t3.asdf
...

etc


elsasoft.org

Is there any way to stop generation multiple rows when you have more than two INNER JOIN?
Thanks.
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2009-04-10 : 02:02:42
you should have waited one more day to post. then it would have been exactly one year!

I assume you mean a given row in table1 shows up multiple times? that doesn't have anything to do with multiple joins. it has to do with the join condition being something other than 1-1.


elsasoft.org
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-04-10 : 06:25:04
you need to then group results based on columns on which you want unique values and apply aggregate over other table columns.
Go to Top of Page
   

- Advertisement -