In article , tshad
wrote:
> Right
>
> but would:
> A JOIN B
> B JOIN C
> C JOIN D
>
> be the same thing as
> A JOIN B
> C JOIN D
> B JOIN C
>
> If so, the 3rd join IS NOT joining against the previous result set.
The above syntax isn't close to valid (no join conditions, no commas to
indicate cross joins), but any way you look at it, the results are the
same (although performance could vary)
select *
from A
inner join B on a.x = b.x
inner join C on b.y = c.y
inner join D on c.z = d.z
Previous results are used at each step.
or
select *
from A
inner join B on a.x = b.x
inner join (select * C inner join D on c.z = d.z) CJ on b.y = CJ.y
Result of A/B combined with results C/D on condition b.y=c.y Because
of the b.y=c.y join condition it doesn't matter how many c/d records
there are, all except the ones that match with b are discarded, because
the c/d condition is the same either way, you get the same number of
records in the end.
The only way it would make a difference is if you meant
select *
from A
cross join B
cross join C
cross join D
cross join B
cross join C
Where you have cartesian joins, and include B and C twice. If you
don't include tables more than once, then cross join or inner join or a
mixture of the two, as long as the same conditions are applied you'll
end up with the same result set.
--
J.B. Moreno
>> Stay informed about: Question on anatomy of a query