Microsoft KB Archive/45301
Article ID: 45301
Article Last Modified on 3/14/2005
- Microsoft SQL Server 4.21a Standard Edition
- Microsoft SQL Server 6.0 Standard Edition
- Microsoft SQL Server 6.5 Standard Edition
This article was previously published under Q45301
The following information discusses how many tables can be involved in an outer join, and the restrictions involved.
Outer joins cannot be nested (t1*=t2*=t3 is illegal), but multiple outer joins are permitted if they aren't nested (t1=*t2*=t3 is allowed).
Inner joins cannot be nested inside the outer join (t1*=t2=t3 is illegal, but t1=t2*=t3 is allowed).
t1*=t2=*t3 is also permitted. It takes the Cartesian product of t1 and t3, then outer-joins the result to t2.
As long as the semantic rules are not violated, the limit is 16 tables, just as with an inner join.
The semantics regarding outer joins can be represented graphically with the tables as nodes and the joins as arcs between the nodes. Outer joins are directed arcs with the arrow pointing to the "inner" table of the pair.
The following is a graphic representation:
select * from t1,t2 where t1.c1*=t2.c1 is t1 --> t2 select * from t1,t2 where t1.c1=*t2.c1 is t1 <-- t2 select * from t1,t2 where t1.c1=t2.c1 is t1 --- t2 illegal legal t1-->t2-->t3 t1-->t2<--t3 t1-->t2<--t3 t1-->t2<--t3 t1<--t2<--t3 | ^ t1<--t2-->t3 | | t1-->t2---t3 | | t1---t2-->t3 +--------+ +--------+ t3 t3 t3 t3 ^ | ^ | | v | v t2<--t1<--t4 t2-->t1-->t4 t2<--t1-->t4 t2-->t1<--t4 | ^ | ^ v | v | t5 t5 t5 t5
Arcs may enter a node or arcs may leave a node, but arcs cannot leave a node that has any arcs entering it.
Additional query words: Transact-SQL
Keywords: kbinfo kbprogramming KB45301