| Join is used to get data from 2 or more tables. There are severa types of joins.
Inner Join is used to get the result from 2 tables. Let suppose there are 2 tables C and D and columns are ID and ID1.
Table
C D
ID ID1
1 3
2 4
3 5
4 6
Inner join return result of C intersect D
select * from C INNER JOIN D on C.ID = D.ID1;
select C.*,D.* from C,D where C.ID = D.ID1;
and result is given below
ID ID1
3 3
4 4
Now comes to Outer join there are 3 outer join tables
(1)Left Outer Join
(2)Right Outer Join
(3)Full Outer Join
Left outer join will return all values from left table and common value from 2 tables
select * from C RIGHT OUTER JOIN D on C.ID = D.ID1;
and Result is given below
ID ID1
1 null
2 null
3 5
4 6
Right Outer join is just opposite of left outer join it will return all values from right table
select C.*,D.* from C,D where C.ID = D.ID1;
ID ID1
3 3
4 4
null 5
null 6
Now comes to last outer join is full outer join here return union of C and D, i.e. all the rows in C and all the rows in D.
select * from C FULL OUTER JOIN D on C.ID = D.ID1;
ID ID1
1 null
2 null
3 3
4 4
null 6
null 5 | | |