---
title: "SQL Joins"  
description: "In this blog, I’m explaining about joins in SQL  SQL joins are used to combine rows from two  or more tables.Types of joins1 .Inner joins2. Outer join"  
author: "priyanka kushwaha"  
published: 2015-01-29  
updated: 2015-01-29  
canonical: https://www.mindstick.com/blog/743/sql-joins  
category: "mssql server"  
tags: ["sql server", "join"]  
reading_time: 2 minutes  

---

# SQL Joins

In this blog, I’m explaining about joins in SQL\

[SQL joins](https://www.mindstick.com/articles/1436/sql-joins) are used to combine rows from two or more tables.

##### Types of joins

1 .Inner joins

2. Outer joins

3. Self joins

##### Inner join

The join that display only the rows that have match in both the joined tables is known as [inner join](https://www.mindstick.com/forum/33572/sql-inner-join-keyword).

##### Example

```
select ed.id, ed.firstName,ed.RoleId,rt.roleName from EmployeeDetail edinner join RoleTable rt on ed.RoleId=rt.roleId
```

##### Different types of inner joins

- Equi join
- [Cross join](https://www.mindstick.com/interview/1850/what-is-cross-join)

##### Equi Join

The Equi join is used to display all the matched records from the joined tables. In this join we need to use * sign to [join the table](https://www.mindstick.com/forum/157565/how-many-ways-to-join-the-table-in-mysql-explain-with-examples).

##### Example

```
select * from EmployeeDetail ed inner join RoleTable rt on ed.RoleId=rt.roleId
```

##### Cross join

A cross join that produces Cartesian product of the tables that involved in the join. The size of a Cartesian product is the number of the rows in the first table multiplied by the number of rows in the second table.

##### Example

```
select * from EmployeeDetailcross  join RoleTable
```

##### Outer joins

A join that return all the rows that satisfy the [condition](https://www.mindstick.com/forum/12711/select-query-with-and-condition) and unmatched rows in the joined table is an outer join.

1. [Left outer join](https://www.mindstick.com/articles/12231/types-of-join-in-sql-server)
2. Right outer join
3. [Full outer join](https://www.mindstick.com/forum/1216/full-outer-join-on-2-data-tables-with-a-list-of-columns)

##### Left outer join

The left outer join displays all the rows from the first table and matched rows from the second table.

##### Example

```
select * from EmployeeDetail edleft outer join RoleTable rt on ed.RoleId=rt.roleId
```

##### Right outer join

The right outer join displays all the rows from the second table and matched rows from the first table.

Example

```
select * from EmployeeDetail edright outer join RoleTable rt on ed.RoleId=rt.roleId
```

##### Full outer join

Full outer join displays all matching and non matching rows of both the tables.

##### Example

```
select * from EmployeeDetail edfull outer join RoleTable rt on ed.RoleId=rt.roleId
```

##### Self join

Joining the table itself called [self join](https://www.mindstick.com/forum/33686/what-is-a-self-join-in-sql-server). Self join is used to retrieve the

\

records having some relation or similarity with other records in the same

\

table.

##### Example

```
select ed.FirstName,rt.RoleName as 'Assign role' from EmployeeDetail edinner join RoleTable rt on ed.RoleId=rt.roleId
```

\

---

Original Source: https://www.mindstick.com/blog/743/sql-joins

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
