Skip to content

JOINS

By using JOINS we can retrive the data from two or more tables

INNER JOIN :

Only matchin records comes from both tables

*** For example

1
2
3
select e.empname,e.salary,d.dept from emp e
inner join dept d 
on e.dept_no=d.dept_no

LEFT JOIN :

All matching + non matching records comes from left table, for non matching null will come in right table

1
2
3
4
select e.empname,e.salary,d.dept
from emp e 
left join dept d
on e.dept_no=d.deptno

RIGHT JOIN :

All matching + non matching records comes from right table, for non matching null will come in left table

1
2
3
4
select e.empname,e.salary,d.dept
from emp e 
right join dept d
on e.dept_no=d.deptno

FULL JOIN :

All matching + non matching records comes from both tables, for non matching null will come in both tables

1
2
3
4
select e.empname,e.salary,d.dept
from emp e 
full join dept d
on e.dept_no=d.deptno

CROSS JOIN :

It is the cartesian product tables two table There is no ON condition

1
2
3
select e.empname,e.salary,d.dept
from emp e 
cross join dept d