user1251973
user1251973

Reputation: 339

Oracle Inner/Outer/Full Join

I have two tables table1 and table2

In table1 i have two columns table1.userid and table2.full_name and in table2 i have two columns table2.userid and table2.ssn

I want records where userid present in both table1 and table2.

Records having userid present in table1 should be ignored if they are present in table2. If not present than want data from table1 also. Also want rest of the data from table2.

Should i use inner/outer/full join?

Can you please help me for the same.

Upvotes: 1

Views: 382

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269763

If you want userids that are present in both tables, then use inner join:

select . . .
from table1 t1 inner join
     table2 t2
     on t1.userid = t2.userid;

If you want all the userids in table1, then use left outer join:

select . . .
from table1 t1 left outer join
     table2 t2
     on t1.userid = t2.userid;

If you want all the useridss in both tables, then use full outer join:

select . . .
from table1 t1 full outer join
     table2 t2
     on t1.userid = t2.userid;

Upvotes: 1

Related Questions