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.
| Author |
Topic |
|
LonnieM
Starting Member
15 Posts |
Posted - 2009-11-06 : 18:01:19
|
| Hello All,I have a query that uses 6 joins to produce a results set. It is in the form of:Select A.field1, B.field2, C.field3, etc....From Table AInner Join Table BOn A.field1 + A.field2 = B.field1 + B.field2Inner Join Table COn A.field1 + A.field2 = C.field1 + C.field2Inner Join Table DOn A.field1 = D.field1 --this is needed to get D.field99Inner Join Table EOn A.field1 + D.field99 = E.field1 + E.field2Inner Join Table DOn A.field1 + D.field99 = F.field1 + F.field2This query runs as expected and the results have been verified. But in looking back at it I confused as to how the SQL Server engine could process two different tables on the same side of the join statement. It seems as though this would not work because the order of processing the joins is left up to SQL Server.Should this work? Would this work in other SQL databases? Is there a better way?....CTE’s etc….Thank you,Lonnie |
|
|
sshelper
Posting Yak Master
216 Posts |
Posted - 2009-11-18 : 00:01:20
|
| Your query should work. SQL Server will know which tables to join first based on the ON conditions of your query. You can even check the order of the tables it joins by looking at the execution plan.Regards,SQL Server Helperhttp://www.sql-server-helper.com/sql-server-2008/connection-error-1326.aspx |
 |
|
|
|
|
|