Join are used to retrives data from two and more tables .table does join with command fileds .
tbl_emp b).tbl_Dept
ID Name Gender Salary Dept_id. ID Dept Location
1 Tom M 4000 1 1 IT London
2 Prema F 5000 3 2 A/C INDIA
3 sam M 3000 4 3 Sales CHINA
4 James F 500 2
Inner Join :
Return only the matching rows between both tables.
example:
Select a.ID,a.Name,a.M,a.Salary,b.Dept
from tbl_emp a inner join tbl_Dept b
on a.ID=b.ID
Left Outer Join :
It is return only matching row but it is retrive all data from left table .
from tbl_emp a left outer join tbl_Dept b
on a.ID=b.IDRight Outer join :
Select a.ID,a.Name,a.M,a.Salary,b.Dept
from tbl_emp a right outer join tbl_Dept b
on a.ID=b.IDSelf Join :
Joining table with itself .
ID Name Gender Salary Mng_id.
1 Tom M 4000 1
2 Prema F 5000 3
3 sam M 3000 4
4 James F 500 2
Select e.Name as Emp_name ,e.Name as Manager
from tbl_emp e inner join tbl_emp m
on e.ID=m.Mng_id
No comments:
Post a Comment