The Wayback Machine - https://web.archive.org/web/20240118172619/https://www.geeksforgeeks.org/full-join-and-inner-join-in-ms-sql-server/
Open In App
Related Articles

Full join and Inner join in MS SQL Server

Improve
Improve
Improve
Like Article
Like
Save Article
Save
Report issue
Report

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

Unlock the Power of Placement Preparation!
Feeling lost in OS, DBMS, CN, SQL, and DSA chaos? Our Complete Interview Preparation Course is the ultimate guide to conquer placements. Trusted by over 100,000+ geeks, this course is your roadmap to interview triumph.
Ready to dive in? Explore our Free Demo Content and join our Complete Interview Preparation course.

Commit to GfG's Three-90 Challenge! Purchase a course, complete 90% in 90 days, and save 90% cost click here to explore.
Last Updated : 14 Jul, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads