---
title: "Explain the difference between an inner join and an outer join in SQL Server."  
description: "Explain the difference between an inner join and an outer join in SQL Server."  
author: "Utpal Vishwas"  
published: 2023-05-16  
updated: 2023-05-16  
canonical: https://www.mindstick.com/forum/158358/explain-the-difference-between-an-inner-join-and-an-outer-join-in-sql-server  
category: "mssql server"  
tags: ["mssql server", "sql server", "sql"]  
reading_time: 2 minutes  

---

# Explain the difference between an inner join and an outer join in SQL Server.

[Explain](https://www.mindstick.com/forum/157854/what-is-system-debugging-explain-some-system-debugging-tools-used-in-modern-computer-systems) the [difference between an inner](https://answers.mindstick.com/qa/31844/what-is-the-difference-between-an-inner-class-and-a-sub-class) join and an [outer](https://answers.mindstick.com/qa/116605/what-is-the-difference-between-inner-join-left-join-right-join-and-full-outer-join) [join in SQL](https://www.mindstick.com/forum/33686/what-is-a-self-join-in-sql-server) Server.

## Replies

### Reply by Aryan Kumar

Sure. An [inner join](https://www.mindstick.com/forum/33572/sql-inner-join-keyword) is a type of join that returns all rows from both tables that have a matching value in the join column. An [outer join](https://www.mindstick.com/forum/159328/mysql-outer-join-syntax-error) is a type of join that returns all rows from both tables, even if there is no matching value in the join column.

Here is an example of an inner join:

Code snippet

```plaintext
SELECT *
FROM Customers
INNER JOIN Orders
ON Customers.CustomerID = Orders.CustomerID;
```

This query will return all rows from the Customers table and all rows from the Orders table where the CustomerID column in the Customers table matches the CustomerID column in the Orders table.

Here is an example of an outer join:

Code snippet

```plaintext
SELECT *
FROM Customers
LEFT OUTER JOIN Orders
ON Customers.CustomerID = Orders.CustomerID;
```

This query will return all rows from the Customers table, even if there are no matching rows in the Orders table. It will also return all rows from the Orders table, even if there are no matching rows in the Customers table. The rows from the Customers table that have no matching rows in the Orders table will have NULL values in the columns from the Orders table. The rows from the Orders table that have no matching rows in the Customers table will have NULL values in the columns from the Customers table.

There are three types of outer joins:

- **LEFT OUTER JOIN:** Returns all rows from the left table, even if there are no matching rows in the right table.
- **RIGHT OUTER JOIN:** Returns all rows from the right table, even if there are no matching rows in the left table.
- **FULL OUTER JOIN:** Returns all rows from both tables, even if there are no matching rows in either table.


---

Original Source: https://www.mindstick.com/forum/158358/explain-the-difference-between-an-inner-join-and-an-outer-join-in-sql-server

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
