Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Outer Join
BigLearner wrote:
> Thanks a bunch for your reply.
>
> That really makes me feel better.
>
> Does the order of the FROM or ON clause matter?
>
> I did try and got some output but I don't understand how the output
> works.
>
> Sorry if thats a lot to ask.
>
> Thanks a bunch once again.
>
> BigLearner
I suspect that I know the answer, but let's confirm. Use the sample tables from the other post:
CREATE TABLE TABLE_1 (ANIMAL VARCHAR2(15)); CREATE TABLE TABLE_2 (ANIMAL VARCHAR2(15)); CREATE TABLE TABLE_3 (ANIMAL VARCHAR2(15)); INSERT INTO TABLE_1 VALUES ('COW'); INSERT INTO TABLE_1 VALUES ('PIG'); INSERT INTO TABLE_1 VALUES ('ZEBRA'); INSERT INTO TABLE_1 VALUES ('SHARK');
INSERT INTO TABLE_2 VALUES ('COW'); INSERT INTO TABLE_2 VALUES ('PIG'); INSERT INTO TABLE_2 VALUES ('DOG'); INSERT INTO TABLE_3 VALUES ('ZEBRA');
TIGER LION ZEBRA
SELECT
T2.ANIMAL T2_ANIMAL,
T3.ANIMAL T3_ANIMAL
FROM
TABLE_2 T2 LEFT OUTER JOIN TABLE_3 T3 ON T2.ANIMAL=T3.ANIMAL;
T2_ANIMAL T3_ANIMAL
=============== ===============
DOG
PIG
COW
SELECT
T2.ANIMAL T2_ANIMAL,
T3.ANIMAL T3_ANIMAL
FROM
TABLE_2 T2 LEFT OUTER JOIN TABLE_3 T3 ON T3.ANIMAL=T2.ANIMAL;
T2_ANIMAL T3_ANIMAL
=============== ===============
DOG
PIG
COW
(Same answer as the above)
SELECT
T2.ANIMAL T2_ANIMAL,
T3.ANIMAL T3_ANIMAL
FROM
TABLE_3 T3 LEFT OUTER JOIN TABLE_2 T2 ON T3.ANIMAL=T2.ANIMAL;
T2_ANIMAL T3_ANIMAL
=============== ===============
TIGER LION ZEBRA
SELECT
T2.ANIMAL T2_ANIMAL,
T3.ANIMAL T3_ANIMAL
FROM
TABLE_2 T2 RIGHT OUTER JOIN TABLE_3 T3 ON T3.ANIMAL=T2.ANIMAL;
T2_ANIMAL T3_ANIMAL
=============== ===============
TIGER LION ZEBRA
Repeat the above using TABLE_1 and one of the other two tables.
Look over the results, and see if you can answer your question: * Does the order of the FROM or ON clause matter?
Charles Hooper
PC Support Specialist
K&M Machine-Fabricating, Inc.
Received on Tue Dec 05 2006 - 06:56:55 CST
![]() |
![]() |