crackyourinterview.com


To improves our performance please Like Share Subscribe(Will boost us)

Difference between Inner Join and Outer Join with Example
Question Posted on 07 Jun 2017Home >> DataBase >> SQL Query >> Difference between Inner Join and Outer Join with Example

Join is used to get data from 2 or more tables. There are severa types of joins.

Inner Join is used to get the result from 2 tables. Let suppose there are 2 tables C and D and columns are ID and ID1.

Table
C     D
ID   ID1
1     3
2     4
3     5
4     6

Inner join return result of C intersect D

select * from C INNER JOIN D on C.ID = D.ID1;
select C.*,D.* from C,D where C.ID = D.ID1;

and result is given below

ID   ID1
3     3
4     4

Now comes to Outer join there are 3 outer join tables
(1)Left Outer Join
(2)Right Outer Join
(3)Full Outer Join

Left outer join will return all values from left table and common value from 2 tables

select * from C RIGHT OUTER JOIN D on C.ID = D.ID1;

and Result is given below

ID   ID1
1     null
2     null
3     5
4     6

Right Outer join is just opposite of left outer join it will return all values from right table

select C.*,D.* from C,D where C.ID = D.ID1;

ID   ID1
3       3
4       4
null     5
null     6


Now comes to last outer join is full outer join here return union of C and D, i.e. all the rows in C and all the rows in D.

select * from C FULL OUTER JOIN D on C.ID = D.ID1;

ID   ID1
1       null
2       null
3       3
4       4
null    6
null    5
0
0



.


Most Visited Questions:-

Deep Learning Questions Answers
Below are the different Deep Leaning Questions and answer a More...

Continuous Integration Questions Answers
Below are the 20 odd questions for CI or Continuous Integra More...

Derived relationships in Association Rule Mining are represented in the form of __________.
Derived relationships in Association Rule Mining are repres More...

What is Gulpjs and some multiple choice questions on Gulp
Gulpjs is an open source whihc helps in building Javascript More...

Microservices Architecture Questions Answers
Below are the different questions on Microservices Architec More...




Other Important Questions

How to get the table count in last used query from cache by sending tablename?

Write a SQL query to print 1 to 100 in sql server?

Sql Interview Latest Query questions asked on 30 dec 2020

nth highest number from table

some good sql query






@2014-2022 Crackyourinterview (All rights reserved)
Privacy Policy - Disclaimer - Sitemap