Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Outer join on multiple columns

TinaMar 15 2016 — edited Mar 17 2016

Hi Gurus,

I need to join tab1 and tab2 using loannbr, userrole1 and userrole2(which can be null).

Basically if userrole1 does not match, we are trying to check userrole2.

We need all rows from tab1 and we need to fetch rfno from tab2.

Is there any solution to this scenario?

I have included the table structure and inserts for your reference.

create table tab1
(loannbr number,
userrole varchar2(25));

insert into tab1 values(100,'DEVELOPER');
insert into tab1 values(200,'QA');
insert into tab1 values(300,'BA');

create table tab2
(loannbr number,
userrole1 varchar2(25),
userrole2 varchar2(25),
rfno number)

INSERT INTO TAB2 VALUES(100,'DEVELOPER', 'DEVELOPER1',1000);

This post has been answered by Paulzip on Mar 15 2016
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 14 2016
Added on Mar 15 2016
18 comments
15,897 views