Sunday, March 11, 2012

double inner join

select a.xxxx, b.xxxxxx, d.xxxxxx
a inner join b where y=z
c inner join d where y=q.
what do these two inner joins do in simple words?
will this be the sum of the two inner joins? As if these were both separate
inner joins and the rows that match are basically appended to the rows that
match of the other. thank you. -hazzEach Join is "Joining" One 'resultset' to another 'resultset'.
a 'resultset' is either a table, or the results of joining ywo other tables
or resultsets.
So if you want to 'join' 4 tables say A, B, C, and D,
you can do it in a variety of ways. I'll put parentheses to show the order
of operations, (omitting Join conditions for clarity (On clauses)
From ( (A Join B ) Join C ) Join D -- This is default order,
without parentheses,
From A Join B Join C Join D
it would do the same,
1) Join A to B
2) Join C with the result of step 1
3) Join D with the resultset from step 2
or, you could...
From (A Join B)
Join
(C Join D)
which would be closest to what you were trying to do,
1) Join A to B
2) Join C to D
3 Join result from Step 1 to result from Step 2
"Hazz" wrote:

> select a.xxxx, b.xxxxxx, d.xxxxxx
> a inner join b where y=z
> c inner join d where y=q.
> what do these two inner joins do in simple words?
> will this be the sum of the two inner joins? As if these were both separat
e
> inner joins and the rows that match are basically appended to the rows tha
t
> match of the other. thank you. -hazz
>
>|||Also, Join conditions must use the 'On' Keyword, not 'Where' for
conditions, so to summarize, your sql should be
Select *
From (A Join B On B.y = A.z)
Join
(C Join D On D.y = C.q)
On C.q = A.q
"Hazz" wrote:

> select a.xxxx, b.xxxxxx, d.xxxxxx
> a inner join b where y=z
> c inner join d where y=q.
> what do these two inner joins do in simple words?
> will this be the sum of the two inner joins? As if these were both separat
e
> inner joins and the rows that match are basically appended to the rows tha
t
> match of the other. thank you. -hazz
>
>|||Thank you very much for your ideas. . thx -greg
"CBretana" <cbretana@.areteIndNOSPAM.com> wrote in message
news:020CB179-05D2-4D56-9815-2CF867A29A04@.microsoft.com...
> Also, Join conditions must use the 'On' Keyword, not 'Where' for
> conditions, so to summarize, your sql should be
> Select *
> From (A Join B On B.y = A.z)
> Join
> (C Join D On D.y = C.q)
> On C.q = A.q
> "Hazz" wrote:
>

No comments:

Post a Comment