Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: SQL question
> Hi ALL
>
> I've two tables and am trying to apply an OUTER JOIN on multiple fields.
>
> Table A has some rows as:
>
><Table A>
><Table B>
First: the (+) is on the right side of the expression, so your statement should read .... t2.number(+) instead of (+)ts.number.
Then: number is a reserved word in Oracle and should not be used for column names, at least not in my opinion.
Here's a working example:
drop table t_a;
drop table t_b;
create table t_a (
u number,
v varchar2(5)
);
create table t_b (
s number,
t varchar2(5)
);
insert into t_a values(1,'a'); insert into t_a values(1,'b'); insert into t_a values(1,'b'); insert into t_a values(3,'a'); insert into t_a values(3,'c'); insert into t_b values(1,'a');
select
t_a.u, t_a.v, t_b.s, t_b.t
t_a.u = t_b.s (+) and t_a.v = t_b.t (+) and t_b.s is null;
Maybe, you want to modify the statement to return distinct values. If so, use
select distinct
instead of
select
A more elegant solution (imho) is here:
select u, v from t_a
minus
select s,t from t_b;
hth
Rene
-- Rene Nyffenegger http://www.adp-gmbh.chReceived on Tue Nov 04 2003 - 16:00:56 CST