Friday, 25 September 2015



Outer Join



There are three type of outer join i.e. Left, right and full outer join. These are given with example.

We have Two given table name table1 and table2, and use it for examples

Table1

Table2


Left outer join

You can use to join two tables, in tis join you will get matching values from given two tables and also you can get un-matched value s from left side table.

Example:

select * from table1 left outer join table2 on table1.dept_name=table2.dept_name;
or
select * from table1,table2 where table1.dept_name=table2.dept_name(+);

Output of left outer join 1st second method


Output of left outer join 2nd second method


 

Right outer join

in tis join you will get matching values from given two tables and also you can get un-matched value s from right side table.

Example:

select * from table1 right outer join table2 on table1.dept_name=table2.dept_name;
or
select * from table1,table2 where table1.dept_name(+) =table2.dept_name;

Output of right outer join 1st second method


Output of right outer join 2nd second method


Full outer join

In this join you will get matching values from given two tables and also you can join two datasets from left-to-right and right-to-left.

Example:

select * from table1,table2 where table1.dept_name=table2.dept_name;
or
select * from table1,table2 where table1.dept_name =table2.dept_name(+) union select * from table1,table2 where table1.dept_name(+) =table2.dept_name;

Output of Full outer join 1st second method


Output of Full outer join 2nd second method



No comments:

Post a Comment