> Can someone assist me? Sorry if this is too complicated.
> I know the ansi syntax for full outer joins does not work in Oracle.
> (I'm using ODBC BTW)
> Can someone tell me
> 1) the syntax and
> 2) can I retrict the scope of the result set as mentioned below?
> Thanks
> Jeff Kish
> table1 part (code, number, alt_num, AlphaNumeric)
> table2 altpart(alt_num, AlphaNumeric)
> table1 = ('code1','part1','alt_num1','part1'),
> ('code2','part_2',NULL,','part2')
> table2 = ('alt_num1','altnum1'),
> ('altnum2','altnum2')
> results of full outer join should be? 1st table1 row joined with 1st
> table2 row and then 2nd table1 row and then 2nd table2 row, not
> necessarily in that order:
> 'code1','part1','alt_num1','part1', 'alt_num1','altnum1'
> 'code2','part_2',NULL,'part2', NULL,NULL
> NULL,NULL,NULL,NULL, 'altnum2','altnum2'
> About limiting the results, .. could I somehow get only entries which
> were related to a certain value of number, say 'part1'
> Thanks again,
> Jeff Kish
You have mentioned different problems.
On ODBC, the original versions did not allow outer joins except as part
of passthru SQL statements. I do not use ODBC, so I am uncertain if
outer joins are supported at the momement.
On syntax, SQL Reference manaul -- chapter 5 on queries and subqueries.
Outer Joins
An outer join extends the result of a simple join. An outer join
returns all rows that satisfy the join condition and those rows from
one table for which no rows from the other satisfy the join condition.
Such rows are not returned by a simple join. To write a query that
performs an outer join of tables A and B and returns all rows
from A, apply the outer join operator (+) to all columns of B in the
join condition.
For all rows in A that have no matching rows in B, Oracle returns NULL
for any select list expressions containing columns of B. See the syntax
for an outer join in "SELECT and Subqueries" on page 7-569.
Outer join queries are subject to the following rules and restrictions:
n The (+) operator can appear only in the WHERE clause or, in the
context of left-correlation (that is, when specifying the TABLE clause)
in the FROM clause, and can be applied only to a column of a table or
view.
[] If A and B are joined by multiple join conditions, you must use the
(+) operator in all of these conditions. If you do not, Oracle will
return only the rows resulting from a simple join, but without a
warning or error to advise you that you do not have the results of an
outer join.
[] The (+) operator can be applied only to a column, not to an
arbitrary expression. However, an arbitrary expression can contain a
column marked with the (+) operator.
[] A condition containing the (+) operator cannot be combined with
another condition using the OR logical operator.
[] A condition cannot use the IN comparison operator to compare a column
marked with the (+) operator with an expression.
[] A condition cannot compare any column marked with the (+) operator
with a subquery.
If the WHERE clause contains a condition that compares a column from
table B with a constant, the (+) operator must be applied to the column
so that Oracle returns the rows from table A for which it has generated
NULLs for this column. Otherwise Oracle will return only the results of
a simple join. In a query that performs outer joins of more than two
pairs of tables, a single table can be the NULL-generated table for
only one other table. For this reason, you cannot apply the (+)
operator to columns of B in the join condition for A and B and
the join condition for B and C.
There are examples in chapter 7 under select and subqueries...
Reading is a good thing.
--
Michael Krolewski
Rosetta Inpharmatics
Usual disclaimers
Sent via Deja.com
http://www.deja.com/