Monday 20 April 2015

What is join in sql server and its types?


Join:-
 Sql server join clause is used to combine rows from two or more tables based on a common field between them(like primary key).
In SQL server 4 different types of joins available:
        Inner join
Inner join  basically two types
(a)  Equi join(return data with duplicate)
(b) Natural join(return data without duplicate)
Outer join
It also divided into 3 types:-
(a)Left outer (all rows from left side and match rows from left side table)
(b)Right outer join (it just opposite of left outer join. All rows from right side table and only matching row from left side table)
(c) Full outer join (all rows from both side if not match then display null).
Self Join:-
It is a special type of join it do not need another table. It is a join in which table is join itself. Especially when the table has a foreign key which references its own primary key.
Cross join:-
A cross join that does not have a WHERE clause produces the Cartesian product of the tables involved in the join. The size of a Cartesian product result set is the number of rows in the first table multiplied by the number of rows in the second table. 

No comments:

Post a Comment