Thursday, August 16, 2012

SQL SERVER – Introduction to JOINs – Basic of JOINs


The nature of relational database design shows that we will have related data that is stored in different tables. To retrieve data from two or more tables we use JOINS.

The JOIN clause tells the database how the data in the two tables is related so that it can return a correct representation of the related data.

There are different types of join. 

1. Self-Join 
2. Inner-Join 
3. Outer-Join 
   3.1 RightOuterJoin 
   3.2 LeftOuterJoin 
   3.3 FullOuterJoin 
4. Cross join 

Self Join : Select e1.emp_name 'manager',e2.emp_name 'employee' 
from employees e1 join employees e2 on e1.emp_id=e2.emp_manager_id 











No comments:

Post a Comment