b). Union is faster then union all
1.tbl_emp1 .
ID F_Name M_Name Salary Mng_id.
1 Tom Null 4000 1
2 Prema Todda 5000 3
2.tbl_emp2 .
ID F_Name M_Name Salary Mng_id.
3 sam Null 3000 4
4 James Parker 500 2
UNION :
select ID , F_Name , M_Name , Salary from tbl_emp1
union
select ID , F_Name , M_Name , Salary from tbl_emp2
Output:
ID F_Name M_Name Salary
1 Tom Null 4000
2 Prema Todda 5000
3 sam Null 3000
4 James Parker 500
UNION ALL :
1.tbl_emp1 .
ID F_Name M_Name Salary Mng_id.
1 Tom Null 4000 1
2 Prema Todda 5000 3
1.tbl_emp2 .
ID F_Name M_Name Salary Mng_id.
1 Tom Null 4000 1
2 Prema Todda 5000 3
select ID , F_Name , M_Name , Salary from tbl_emp1
union ALL
select ID , F_Name , M_Name , Salary from tbl_emp2
Output :
ID F_Name M_Name Salary Mng_id.
1 Tom Null 4000 1
2 Prema Todda 5000 3
1 Tom Null 4000 1
2 Prema Todda 5000 3
Note :
Union is join row between two or more table while JOIN is join the column between two and more table .
No comments:
Post a Comment