Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Difference between Inner and Outer join in SQL
In Relational database tables are associated with each other and we used foreign key to maintain relationships between tables. We used join clause to retrieve data from associated tables. The join condition indicates how column in each table are matched against each other.
There are two types of joins clause in SQL
- Inner join
- Outer join
Outer join is again divided into parts −
- LEFT OUTER JOIN - It will return all data of the left table and matched records in both table
- RIGHT OUTER JOIN - it will return all the data of the right table and matched records in both table
| Sr. No. |
Key |
Inner join |
Outer join |
|---|---|---|---|
1 |
Basic |
It can be used to retrieve only matched records between both tables |
It is used to retrieve all matching records as well non matching records of the tables |
2 |
Return |
It doesn't return anything when match is not found. |
It return null in the column values |
3 |
Performance |
It is faster than outer join. |
It is slower than inner join because of the larger result set |
Example of OUTER JOIN
SELECT columnnameList FROM tableA FULL OUTER JOIN tableB ON tableA.column_name = tableB.column_name WHERE condition;
Example of INNER JOIN
SELECT columnlist FROM TableA INNER JOIN TableB ON join condition
