How do you know which table is the intermediate or translation table in a
query using multiple joins.
For example:
SELECT T1.ID
FROM T1 LEFT OUTER JOIN T2 on T1.ID = T2.ID LEFT OUTER JOIN T3 ON T1.ID =
T3.ID
WHERE (T2.ID IS NULL) AND (T3.ID IS NULL)
T1
--
A
B
C
D
E
T2
--
A
X
B
Y
T3
--
B
H
R
J
K
X
E
Results of the query is:
C
D
In the above query is T2 the intermediate table or is it T1'
In both "ON" clauses T1 is used. This confuses me as to which table is the
intermediate.
Is there a way to use parenthesis to clarify the precedence or anything?
Thanks,
GeoffSELECT T1.ID
FROM T1
LEFT OUTER JOIN T2
on T1.ID = T2.ID
LEFT OUTER JOIN T3
ON T1.ID = T3.ID
WHERE (T2.ID IS NULL) AND (T3.ID IS NULL)
There is no "intermediate" table as I would think about that in an n:m
realtionsship. As it seems, the tabels all have the same primary keys which
sounds that they dont build up a many2many relationship. (Perhaps if you
would post up your real example and some DDL that would clarify the
situation a bit)
> Is there a way to use parenthesis to clarify the precedence or anything?
I always put tabs between the expression to chop up the important parts of
th query. (see above)
--
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
"Geoff" <Geoff@.discussions.microsoft.com> schrieb im Newsbeitrag
news:3D111A57-3DB2-4202-A6BD-F1530880A665@.microsoft.com...
> How do you know which table is the intermediate or translation table in a
> query using multiple joins.
> For example:
> SELECT T1.ID
> FROM T1 LEFT OUTER JOIN T2 on T1.ID = T2.ID LEFT OUTER JOIN T3 ON T1.ID =
> T3.ID
> WHERE (T2.ID IS NULL) AND (T3.ID IS NULL)
> T1
> --
> A
> B
> C
> D
> E
> T2
> --
> A
> X
> B
> Y
> T3
> --
> B
> H
> R
> J
> K
> X
> E
>
> Results of the query is:
> C
> D
>
> In the above query is T2 the intermediate table or is it T1'
> In both "ON" clauses T1 is used. This confuses me as to which table is the
> intermediate.
> Is there a way to use parenthesis to clarify the precedence or anything?
> Thanks,
> Geoff
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment