Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Select with dual-field empty

0 views
Skip to first unread message

Sonnich

unread,
Oct 19, 2006, 12:28:56 PM10/19/06
to
Hi

I havent touched oracle for some time...

I want to do a select from 2 tables, where the connection between the
tables are fields, but the row migth not exist

e.g.

select * from a, b where a.code=b.code(+), but like this:

select * from a, b
where a.code1=b.code1(+)
and a.code2=b.code2(+)

the point is that both code1 and 2 has to be there.

Any idea how I can do this?

BR
Sonnich

Martin T.

unread,
Oct 19, 2006, 3:39:48 PM10/19/06
to

Maybe:


select * from a, b
where a.code1=b.code1(+)
and a.code2=b.code2(+)

AND (CODE1 IS NOT NULL AND CODE2 IS NOT NULL)

... maybe it could also be written with the explicit LEFT OUTER JOIN ..
ON syntax ...

cheers,
Martin

DA Morgan

unread,
Oct 19, 2006, 3:43:56 PM10/19/06
to

WHERE a.code1 IS NOT NULL
AND a.code2 IS NOT NULL

But given that NULL <> NULL I'm not sure you actually have an issue.
--
Daniel A. Morgan
University of Washington
damo...@x.washington.edu
(replace x with u to respond)
Puget Sound Oracle Users Group
www.psoug.org

mgil...@uoguelph.ca

unread,
Oct 23, 2006, 9:17:48 AM10/23/06
to
I may be wrong in this instance, but isn't there a problem with the
original SQL statement because your creating two outer joins on the
same table ( Table 'b' )? Or does this error not occur because they're
different fields.

Cheers,

Mitch

G Quesnel

unread,
Oct 23, 2006, 9:28:49 AM10/23/06
to

It's perfectly legitimate, as a single outer join based on multiple
columns.
FYI - you could also have ...
where a.code1=b.code1(+)
and a.code2=b.code2
which represent a different business requirement.
hth

0 new messages