---
title: "JOIN in SQL Server"  
description: "SQL JOIN's are used to query data from two or more tables, based on a relationship between certain columns in these tables.SQL joins are used to combi"  
author: "Anonymous User"  
published: 2012-03-31  
updated: 2014-09-18  
canonical: https://www.mindstick.com/blog/291/join-in-sql-server  
category: "database"  
tags: ["database"]  
reading_time: 2 minutes  

---

# JOIN in SQL Server

[SQL JOIN](https://www.mindstick.com/articles/11997/sql-joins-in-sql-server)'s are used to [query data](https://www.mindstick.com/forum/914/facebook-cronjob-login-and-query-data) from two or more tables, based on a [relationship](https://yourviews.mindstick.com/view/80835/phubbing-is-the-relationship-killer) between certain columns in these tables.[SQL joins](https://www.mindstick.com/articles/1436/sql-joins) are used to combine rows from two or more tables.

##### In the examples below I am going to take following two tables.

![JOIN in SQL Server](https://www.mindstick.com/blogs/50e4e8ba-6bc6-4f25-932c-a10f66dcb219/images/eb07a413-1b61-462e-9f6c-de4f8589a054.jpg)![JOIN in SQL Server](https://www.mindstick.com/blogs/50e4e8ba-6bc6-4f25-932c-a10f66dcb219/images/17b4e38c-1f99-4d34-9e55-9992a0387cd3.png)

##### In this blog I am going to discuss about two JOIN type:

1. [INNER JOIN](https://www.mindstick.com/forum/33572/sql-inner-join-keyword)
2. [OUTER JOIN](https://www.mindstick.com/forum/159328/mysql-outer-join-syntax-error)

##### INNER JOIN

The INNER JOIN keyword return rows when there is at least one match in both tables.

##### Example

```
SELECT * FROM Table1 t1 INNER JOIN Table2 t2 ON t1.ID = t2.ID
```

##### Output

![JOIN in SQL Server](https://www.mindstick.com/blogs/50e4e8ba-6bc6-4f25-932c-a10f66dcb219/images/4479160d-7bb4-40a2-ba20-19a1bf983d2a.png)

##### OUTER JOIN

##### There are three types of OUTER JOIN’s

1. LEFT OUTER JOIN
2. RIGHT OUTER JOIN
3. FULL OUTER JOIN

##### LEFT OUTER JOIN

LEFT OUTER JOIN returns all the rows from the left table in conjunction with the matching rows from the right table. If there are no columns matching in the right table, it returns NULL values.

##### Example

```
SELECT * FROM Table1 t1 LEFT OUTER JOIN Table2 t2 ON t1.ID = t2.ID
```

##### Output

![JOIN in SQL Server](https://www.mindstick.com/blogs/50e4e8ba-6bc6-4f25-932c-a10f66dcb219/images/d55f398f-ca4a-46fb-a4d5-822f7abddd85.png)

##### RIGHT OUTER JOIN

RIGHT OUTER JOIN returns all the rows from the right table in conjunction with the [matching](https://www.mindstick.com/forum/162034/what-is-semantic-matching) rows from the left table. If there are no columns matching in the left table, it [returns NULL](https://www.mindstick.com/forum/159370/sql-join-returns-null-records-when-there-is-no-data-in-the-database-in-sql-server-why) values.

##### Example

```
SELECT * FROM Table1 t1 RIGHT OUTER JOIN Table2 t2 ON t1.ID = t2.ID
```

##### Output

### ![JOIN in SQL Server](https://www.mindstick.com/blogs/50e4e8ba-6bc6-4f25-932c-a10f66dcb219/images/215a0fcb-a120-4553-b8fd-e80b0c8a8611.png)

##### FULL OUTER JOIN

FULL OUTER JOIN returns rows from either table when the conditions are met and returns null value when there is no match.

##### Example

```
SELECT * FROM Table1 t1 FULL OUTER JOIN Table2 t2 ON t1.ID = t2.ID
```

##### Output

### ![JOIN in SQL Server](https://www.mindstick.com/blogs/50e4e8ba-6bc6-4f25-932c-a10f66dcb219/images/e83678e4-16ed-40c6-b4dd-7be7210d3636.png)

##### *You can also visit these related post*

[https://www.mindstick.com/Articles/35/join-in-sql-server](https://www.mindstick.com/Articles/35/join-in-sql-server)\
[https://www.mindstick.com/Articles/450/joins-in-sql-server](https://www.mindstick.com/Articles/450/joins-in-sql-server)\
\

---

Original Source: https://www.mindstick.com/blog/291/join-in-sql-server

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
