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)
 Newbie Join question

Author  Topic 

evaaseow
Starting Member

1 Post

Posted - 2007-08-22 : 10:31:23
Hi All, i've been trying to get back into the SQL world after being away for quite sometime.

I was wondering about multiple table joins and how joins work from the background.

Select *
FROM
table1 LEFT OUTER JOIN
ON table1.field = table2.field
table2 INNER JOIN
ON table1.field = table3.field
table3 INNER JOIN
ON table3.field = table4.field
table4

From the example i have a couple of questions.

1) Does it matter which order the tables/joins appear
2) When matching fields does it matter which order they appear?
3) How does the field matching work with respect to linking tables?

Thank You.

mwjdavidson
Aged Yak Warrior

735 Posts

Posted - 2007-08-22 : 11:39:10
[code]Select *
FROM
table1 LEFT OUTER JOIN table2
ON table1.field = table2.field
INNER JOIN table3
ON table1.field = table3.field
INNER JOIN table4
ON table3.field = table4.field[/code]

1. No
2. No (but be consistent)
3. Huh!?

Mark
Go to Top of Page
   

- Advertisement -