JOINS:
By using Joins we can combine rows from 2 or more tables
based on a related column.
Emp table
E_id |
E_name |
Designation |
1 |
sai |
developer |
2 |
ram |
tester |
3 |
krish |
architect |
Emp_personal table
E_id |
E_sal |
Mail |
1 |
10000 |
s@gmail.com |
4 |
20000 |
r@gmail.com |
3 |
30000 |
k@gmail.com |
1.Inner Join:
· It displays matching data from both the tables
Select emp.*,emp_personal.* from emp Inner Join emp_personal ON emp.e_id=emp_personal.e_id;
2.Left Join:
· Displays all records from left table and matching records from right table
Select emp.*,emp_personal.* from emp Left Join emp_personal ON emp.e_id=emp_personal.e_id;
3.Right Join:
· Displays all records from right table and matching records from left table
Select emp.*,emp_personal.* from emp Right Join emp_personal
ON emp.e_id=emp_personal.e_id;
4.Full Outer Join:
· It displays all records from both the tables whether condition matched or not for left and right tables
Select emp.*,emp_personal.* from emp Full Join emp_personal
ON emp.e_id=emp_personal.e_id;
5.Self Join:
· It displays the data from the same table
· One table consider as 2 tables
· It Join the table by itself
EManager table
E_id |
E_name |
M_id |
1 |
sai |
1 |
2 |
ram |
4 |
3 |
krish |
5 |
Select *from EManager Inner Join EManager ON EManager.E_id=EManager.M_id;
No comments:
Post a Comment