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.
Name | Rollno | Age | Course |
---|---|---|---|
Ayra | 111 | 19 | CSE |
Mona | 112 | 18 | EEE |
Veena | 113 | 19 | ECE |
Neena | 114 | 18 | Mech |
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 |
Please Login to comment...