×

SQL FULL JOIN

In this section, we will help you understand the concept of the SQL FULL Join clause with a few examples.

The SQL FULL Join query is executed to display the integrated results of the left join and right join.

The SQL FULL Join query display all the data, and the NULL value is returned at the missing place of the record.

The syntax of the SQL FULL Join is as follows:

SELECT table1.column_name1, table1.columnname2, table1.column_name3, table1.columnname4, table2.column_name1, table2.column_name2, table2.column_name3, table2.column_name4 FROM table1 FULL JOIN table2;

Let’s understand the SQL FULL Join with the help of examples.

Assume the following table, which has certain data.

Table Name 1- D_Students

Student_IdStudent_NameFirst_ SemesterSecond_ SemesterThird_ SemesterFourth_ SemesterFifth_ SemesterSixth_ SemesterTotalDepartment_ Id
202111Vineeta Sharma938885859592905
202112Vaibhav Lokhande859092808582862
202113Yash Dhull908894878590893
202114Sonali Patole959092889290914
202115Amit Sonar858382869284851
202116Meena Mishra787580748577783
202117Mahesh Kumbhar758375788076825
202118Sakshi Patil807874788077832
202119Sopan Bhore706875758080802
202220Prajwal Lokhande808585757880864
202221Anuja Wanare858886828485854
202222Venkatesh Iyer908987909291903
202223Anushka Sen707571748078801
202224Aakash Jain807572748580832
202225Akshay Agarwal858378889082893
202226Shwetali Bhagwat908385889080861
202227Priya Wagh808385808285874
202228Saurabh Sangale858380908484895
202229Manthan Koli857584788280862
202230Mayur Jain808887909290881

Table Name 2- Department

Department_IdDepartment_Name
1Computer Engineering
2Information Technology
3Mechanical Engineering
4Automobile Engineering
5Civil Engineering
6Electrical Engineering

Example 1: Write a query on the D_students and Department table where the second_semester percentage is 78.

SELECT Student_Id, Student_Name, First_Semester, Second_Semester, Third_Semester, Fourth_Semester, Fifth_Semester, Sixth_Semester, Total, Department_Name FROM D_Students FULL JOIN Department WHERE Second_Semester = 78;  

The above SQL FULL Join query joins the D_Students table and department, and displaying the records where the second_semester percentage is 78.

The output of the above example is as follows:

Student_IdStudent_NameFirst_ SemesterSecond_ SemesterThird_ SemesterFourth_ SemesterFifth_ SemesterSixth_ SemesterTotalDepartment_Name
202218Sakshi Patil80787478807783Computer Engineering
202218Sakshi Patil80787478807783Information Technology
202218Sakshi Patil80787478807783Mechanical Engineering
202218Sakshi Patil80787478807783Automobile Engineering
202218Sakshi Patil80787478807783Civil Engineering
202218Sakshi Patil80787478807783Electrical Engineering
SQL FULL JOIN

Example 2: Write a query on the D_students and Department table where Student_Name start with the letter ‘A’.

SELECT Student_Id, Student_Name, First_Semester, Second_Semester, Third_Semester, Fourth_Semester, Fifth_Semester, Sixth_Semester, Total, Department_Name FROM Department FULL JOIN D_Students WHERE Student_Name LIKE 'A%';

The above SQL FULL Join query joins the D_Students table and department, and displaying the records where the Student_Name is start with the letter 'A'.

The output of the above example is as follows:

Student_IdStudent_NameFirst_ SemesterSecond_ SemesterThird_ SemesterFourth_ SemesterFifth_ SemesterSixth_ SemesterTotalDepartment_Name
202115Amit Sonar85838286928485Computer Engineering
202115Amit Sonar85838286928485Information Technology
202115Amit Sonar85838286928485Mechanical Engineering
202115Amit Sonar85838286928485Automobile Engineering
202115Amit Sonar85838286928485Civil Engineering
202115Amit Sonar85838286928485Electrical Engineering
202221Anuja Wanare85888682848585Computer Engineering
202221Anuja Wanare85888682848585Information Technology
202221Anuja Wanare85888682848585Mechanical Engineering
202221Anuja Wanare85888682848585Automobile Engineering
202221Anuja Wanare85888682848585Civil Engineering
202221Anuja Wanare85888682848585Electrical Engineering
202223Anushka Sen70757174807880Computer Engineering
202223Anushka Sen70757174807880Information Technology
202223Anushka Sen70757174807880Mechanical Engineering
202223Anushka Sen70757174807880Automobile Engineering
202223Anushka Sen70757174807880Civil Engineering
202223Anushka Sen70757174807880Electrical Engineering
202224Aakash Jain80757274858083Computer Engineering
202224Aakash Jain80757274858083Information Technology
202224Aakash Jain80757274858083Mechanical Engineering
202224Aakash Jain80757274858083Automobile Engineering
202224Aakash Jain80757274858083Civil Engineering
202224Aakash Jain80757274858083Electrical Engineering
202225Akshay Agarwal85837888908289Computer Engineering
202225Akshay Agarwal85837888908289Information Technology
202225Akshay Agarwal85837888908289Mechanical Engineering
202225Akshay Agarwal85837888908289Automobile Engineering
202225Akshay Agarwal85837888908289Civil Engineering
202225Akshay Agarwal85837888908289Electrical Engineering
SQL FULL JOIN

Related Topics

SQL Cloning Tables

Cloning a Table: To create a copy of the table. To perform the operations, without affecting the actual table. Steps for creating a Cloning Table: Step 1: Empty Table Creation The syntax for Creating...

3 minutes read.

Difference between SQL and NoSQL

SQL vs. NoSQL | Difference between SQL and NoSQL Choosing a database is the most fundamental decision that needs to be decided before starting a task. Relational and non-relational databases are...

3 minutes read.

How to drop a column in SQL?

How to drop a column in SQL Introduction To delete a column from an already created table, one needs to use the ALTER command along with the DROP COLUMN clause. Syntax: ALTER TABLE tablename...

4 minutes read.

TCL Commands in SQL

In Structured Query Language, TCL is an abbreviation for Transaction Control Language. A single unit of work in a database is formed after the consecutive execution of commands is known...

6 minutes read.

SQL Truncate

This command deletes all records from table. Truncate is a DDL command. Syntax: TRUNCATE table table_name; Example: Truncate table teacher; ORDER BY The ORDER BY clause arranges the table or column in ascending...

5 minutes read.

SQL SELECT Database

In this tutorial, we will help you to understand and learn how to select the database in SQL with the help of examples. The database user or the administrator wants to...

3 minutes read.

SQL CONSTRAINTS

SQL Constraints specifies the rules/limitations/restrictions for data present in table. SQL Constraints are specified at the time of table creation or after table creation using ALTER command. There are two...

5 minutes read.

SQL SELECT IN

SQL SELECT IN is a logical operator in Structured Query Language. It is used in SQL queries to reduce the use of multiple 'OR' operators. s The IN operator in SQL...

6 minutes read.

SQL WHERE Statement

SQL WHERE Statement Introduction WHERE clause is used to include a condition while fetching data from tables.When you have to specify a condition that has to be obeyed while data is...

9 minutes read.

GROUP BY vs ORDER BY

The GROUP BY clause and ORDER BY clause in SQL are used to arrange data obtained by SQL queries. The important difference between the GROUP BY clause and ORDER BY...

4 minutes read.

SQL Aggregate Functions

In this tutorial, we will learn and understand the SQL Aggregate Functions concept with the help of examples. SQL Aggregate Function is a function used to perform calculation operations on one...

4 minutes read.

SQL IN vs SQL EXISTS

SQL IN vs SQL EXISTS This article discusses in detail about the IN and the EXISTS operators in SQL. It is a common question between developers that what is the difference...

3 minutes read.

SQL Queries

In a database, queries are used to request the result set of data from the table or action on the records. A Query can answer your simple or complicated question, perform...

5 minutes read.

Commit and Rollback in SQL

In Structured Query Language, we have Data Definition Language (DDL) and Data Manipulation Language (DML) commands the same way we have Transaction Control Language (TCL) commands in the Structured Query...

4 minutes read.

SQL Primary Key

A field, which contains unique data in a table, is called a PRIMARY KEY (PK). It means, a PRIMARY KEY field must contain unique data in the table. A PRIMARY KEY...

4 minutes read.

SQL UPDATE

SQL UPDATE The SQL UPDATE statement is utilized to update and modify the records present into a database. It is used to change the already existing records stored in the tables...

3 minutes read.

SQL Syntax

In this tutorial, we will help you understand about the different SQL Syntax concepts with the help of an example. Every Structured Query Language starts with Keywords like select, insert, update,...

5 minutes read.

SET Operators in SQL

The operator used to join or combine two queries is none other than SET operators. Operators categorized into SET operators are as follows: UNION Operator.UNION ALL’ Operator.INTERSECT Operator.MINUS Operator. Rules to be...

8 minutes read.

SQL Insert multiple rows

This article will deal with a new insertion method in SQL which inserts multiple rows at a time. Multiple records can be inserted at a time into a specific table with...

4 minutes read.

SQL DROP Database

This tutorial will help us understand how to drop a database from the SQL Server with a few examples. The DROP command removes all the objects stored in the database and...

4 minutes read.