Difference between JOIN and inner join [message #7905] |
Wed, 16 July 2003 10:57 |
shashi
Messages: 34 Registered: March 2001
|
Member |
|
|
What is the difference between JOIN keywrod and the inner join??
Example -
Select * from a , b where a.id = b.id
&
Select * from a JOIN on b .......I am not sure how to use this exactly.
Thanks
|
|
|
|
|
Re: Difference between JOIN and inner join [message #7963 is a reply to message #7957] |
Fri, 18 July 2003 15:01 |
|
Barbara Boehmer
Messages: 9090 Registered: November 2002 Location: California, USA
|
Senior Member |
|
|
A FULL OUTER JOIN is the combined results of a LEFT OUT JOIN and RIGHT OUTER JOIN. I have provided an example of LEFT OUTER JOIN, RIGHT OUTER JOIN, then FULL OUTER JOIN below. I have provided both the 9i ANSI SQL syntax and 8i syntax, which is still usable in 9i, but I have only run the 8i syntax, since I am using 8i. Also, the OUTER keyword is optional, so, for example, LEFT OUTER JOIN is the same as LEFT JOIN.
SQL> -- test data:
SQL> SELECT * FROM a
2 /
ID COL2
---------- -------------------------
1 id value in both tables
2 id value in table a only
SQL> SELECT * FROM b
2 /
ID COL2
---------- -------------------------
1 id value in both tables
3 id value in table b only
SQL> -- left outer join with 9i syntax:
SQL> -- SELECT a.id, a.col2, b.id, b.col2
SQL> -- FROM a LEFT OUTER JOIN b ON a.id = b.id
SQL> -- /
SQL> -- left outer join with 8i syntax:
SQL> SELECT a.id, a.col2, b.id, b.col2
2 FROM a, b
3 WHERE a.id = b.id (+)
4 /
ID COL2 ID COL2
---------- ------------------------- ---------- -------------------------
1 id value in both tables 1 id value in both tables
2 id value in table a only
SQL> -- right outer join with 9i syntax:
SQL> -- SELECT a.id, a.col2, b.id, b.col2
SQL> -- FROM a RIGHT OUTER JOIN b ON a.id = b.id
SQL> -- /
SQL> -- right outer join with 8i syntax:
SQL> SELECT a.id, a.col2, b.id, b.col2
2 FROM a, b
3 WHERE a.id (+) = b.id
4 /
ID COL2 ID COL2
---------- ------------------------- ---------- -------------------------
1 id value in both tables 1 id value in both tables
3 id value in table b only
SQL> -- full outer join with 9i syntax:
SQL> -- SELECT a.id, a.col2, b.id, b.col2
SQL> -- FROM a FULL OUTER JOIN b ON a.id = b.id
SQL> -- /
SQL> -- full outer join with 8i syntax:
SQL> SELECT a.id, a.col2, b.id, b.col2
2 FROM a, b
3 WHERE a.id = b.id (+)
4 UNION ALL
5 SELECT a.id, a.col2, b.id, b.col2
6 FROM a, b
7 WHERE a.id (+) = b.id
8 AND a.id IS NULL
9 /
ID COL2 ID COL2
---------- ------------------------- ---------- -------------------------
1 id value in both tables 1 id value in both tables
2 id value in table a only
3 id value in table b only
|
|
|
|
|