Types of Joins in Sql Server 2005

Updated on 09 Jan 2012,
Published on 28 Feb 2008

First of all take a look on the names of different types of joins in SQL. 

  1. Inner Join
  2. Outer Join
    • Left Outer Join
    • Right Outer Join
    • Full Outer Join
  3. Cross Join

Joins in SQL Server allows the retrieval of data records from one or more tables having some relation between them. Logical operators can also be used to drill down the number of records to get the desired output from sql join queries.

1. Inner Join

Inner Join is a default type join of SQL Server. It uses logical operators such as =, <, > to match the records in two tables. Inner Join includes equi join and natural joins.

Examples

SQL Inner Join Examples

SQL Inner Natural Join Examples

SQL Inner Equi Join Examples

2. Outer Join

Outer Join has further 3 sub categories as left, right and full. Outer Join uses these category names as keywords that can be specified in the FROM clause.

2.1 Left Outer Join

Left Outer Join returns all the rows from the table specified first in the Left Outer Join Clause. If in the left table any row has no matching record in the right side table then that row returns null column values for that particular tuple.

Examples

SQL Left Outer Join Examples

2.2 Right Outer Join

Right Outer Join is exactly the reverse method of Left Outer Join. It returns all the rows from right table and returns null values for the rows having no match in the left joined table.

Examples

SQL Right Outer Join Examples 

2.3 Full Outer Join

Full outer join returns all the rows from both left and right joined tables. If there is any match missing from the left table then it returns null column values for left side table and if there is any match missing from right table then it returns null value columns for the right side table.

Examples

SQL Full Outer Join Examples 

3. Cross Join

Cross join works as a Cartesian product of rows for both left and right table. It combined each row of left table with all the rows of right table.

Examples

SQL Cross Join Cartesian product Examples

Other SQL Join Examples

Joins In Sql Server 2005

Joins using table aliases in SQL Server 2005

Also  read the tutorial: Self Join In Sql Server 2000 2005 to learn how to apply the self join to the sql server table to fetch the inter-related data from a single table.

14 Responses to "Types of Joins in Sql Server 2005"
Mahua Mitra
It was really helpfull thank you
srinivasa rao
its would very useful to me...
this is good introduction of join
thanks everybody
ganesh
can a table have two primary keys??
ganesh
can a table have two primary keys?? pls reply the ans to ma mail
Nashfana
ya its very good description about join.
Atcheswar Reddy
Hi, you done Good Job...it would very usefull to me... Thank You
Janakiraman
Hi,
Its good, very useful to my interviews.
manoj bhatt
very good for me
manoj bhatt
this is very helpfull for me
thanks
Harikrishna
very very nice useful get more knowledge from this site, thank you for posting
Lalit Raghuvanshi
thanks for such a useful article..It cleared my lots of basic concepts..
Neetu Gupta
Thanks for giving such information about joins
Neetu Gupta
Thanks for giving such information about joins There is one another type of join that is self join.
Leave a Comment
* required
* required
* will not be published
* optional
* hint: http://www.example.com
  • Subscribe via Email
  • HIRE EzineASP.Net Developers