Full join and Inner join in MS SQL Server

Prerequisite – Introduction of MS SQL Server
1. Full Join :
Full join selects all the rows from left and the right tables along with the matching rows as well. If there are no matching rows, it will be displayed as NULL.

Syntax –

select select_list 
from table1 full join table2 on join _predicate
                           (OR)
select * 
from table1 full join table2



2. Inner Join :
Inner join retrieves the rows that match from left and right tables. If there are no matching rows, NULL is displayed.

Syntax –

select select_list 
from table1 inner join table2 on join_predicate
                        (OR)
select * 
from table1 inner join table2 

Note –
These joins can be applied to multiple tables.





Example –
There are two tables namely Student and Marks from the university database given below.

Table – Student

Name Rollno Age Course
Ayra 111 19 CSE
Mona 112 18 EEE
Veena 113 19 ECE
Neena 114 18 Mech


Table – Mark

Name Rollno Course GPA
Ayra 111 CSE 9.6
Mona 112 EEE 9.5
Veena 113 ECE 7.7
Neena 114 Mech 7.5



1. Full Join :
Full join is applied to the tables Student and Marks and the table below is the result set.

select * 
from student full join marks 

Name Rollno Age Course GPA
Ayra 111 19 CSE 9.6
Mona 112 18 EEE 9.5
Veena 113 19 ECE 7.7
Neena 114 18 Mech 7.5



2. Inner join :
Inner join is applied to the tables Student and Marks and the table below is the result set.

select * 
from student inner join marks 

Name Rollno Course
Ayra 111 CSE
Mona 112 EEE
Veena 113 ECE
Neena 114 Mech

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.