EDUCBA Logo

EDUCBA

MENUMENU
  • Explore
    • EDUCBA Pro
    • PRO Bundles
    • Featured Skills
    • New & Trending
    • Fresh Entries
    • Finance
    • Data Science
    • Programming and Dev
    • Excel
    • Marketing
    • HR
    • PDP
    • VFX and Design
    • Project Management
    • Exam Prep
    • All Courses
  • Blog
  • Enterprise
  • Free Courses
  • Log in
  • Sign Up
Home Data Science Data Science Tutorials DBMS Tutorial dbms join
 

dbms join

Updated March 31, 2023

dbms join

 

 

Introduction to dbms join

dbms join is a very important concept when we want to fetch the data or record from two tables based on the common attribute of both the tables. Joins are divided into different types, and it is one of the most important concepts of relational databases. We have different types of joins: inner join, outer join, left join, right join, and many more. So when we want to fetch data from multiple tables and when we deal with so many tables based on the mapping joins is very helpful; it helps us to get the data or records from different tables. It is also one of the most asked interview topics. So, in short, we can define joins in a relational database as the Cartesian product of two tables; it consists of selection and product process to get the desired result from multiple tables. In the coming section of the tutorial, we will be going to see in more detail about the joins with each type detailed explanation.

Watch our Demo Courses and Videos

Valuation, Hadoop, Excel, Mobile Apps, Web Development & many more.

Types of Join

dbms joins are broadly divided into mainly two types, and these types are further divided into subtypes. All of the types have their own significance, and we can use each of them in our application to get the desired result from the database tables. Hence it helps us to join multiple tables and get the result out of that based on the selection process; let’s get quickly start a discussion about the type of join we have seen below;

The broad view for different types of joins is a follows;

1) inner join

2) outer join

let’s discuss each of them in detail;

1) Inner Join: Inner join is the most common form of joins in dbms; this joins helps us to get the common result from both the tables. This uses a common attribute from both tables to map the data from each table. We can select specific fields or all the attributes of both fields to get the result. Based on the id provided commonly in both tables, it will return the match record from both the tables. Let take a look at the diagram to understand this Cartesian product from the tables see below;

Diagram:

Image1

Syntax:

SELECT your columns(s)
FROM table_one
INNER JOIN table_two
ON table_one.column_name = table_two.column_name;

As you can see from the above syntax, we are trying to make use of inner use; for that, we are using ‘inner join’ as the keyword to join two tables. Let’s take a closer look at the query, which will help you understand the query well;

Inner Join Query:

SELECT cus.CustomerName, cus.City, cus.Country, ord.OrderID, ord.EmployeeID
FROM Orders as ord
INNER JOIN Customers as cus ON ord.CustomerID = cus.CustomerID;

Output:

dbms join output 1

Now inner join can be further divided into two more subtypes which is mentioned in the below points; let’s take a detailed look at both of them see below;

i) Equi Join: This is one of the types of inner join itself, which makes use of equivalence condition and based in that it tries to fetch the record from both the tables. In this section, we will see a closer look at the syntax and query see below;

Equi Join Query:

SELECT cus.CustomerName, cus.City, cus.Country, ord.OrderID, ord.EmployeeID
FROM Orders as ord
INNER JOIN Customers as cus ON ord.CustomerID = cus.CustomerID;

Output:

dbms join output 2

ii) Natural Join: It is also one of the types of inner join which makes use of common attributes in both tables to return the result record; it does not depend on or use any comparison operator to get the result or join two tables. This can also be created using the ‘Natural join’ keyword while writing the query using natural join. Let’s take a closer look at the syntax and query for a better understanding of this join in detail see below;

Natural Join Query:

Select * from Orders Natural Join Customers;

Output:

dbms join output 3

2) Outer Join: Now, the second type of join we have is outer join, which is further divided into subcategories to get the desired results from the multiple tables; whether there is a match or not in both the tables depends on which type of outer join we are using. Let’s take a closer look at all the types available in it to see below;

i) Left-outer join: This is one of the most common type outer join we have. for this, we use the ‘left join’ keyword inside the query to get the result. But it does return the record differently; let understand this, This basically returns all the records from the first table, that is, the left table, with the matching record found in the right table or the second table. Let’s understand this by a simple diagram for better clarity see below;

Diagram:

Image2

Syntax:

SELECT cus.CustomerName, cus.City, cus.Country, ord.OrderID, ord.EmployeeID
FROM Orders as ord
LEFT OUTER JOIN Customers as cus ON ord.CustomerID = cus.CustomerID;

Output:

output 4

ii) Right outer join: This is one of the most common types of outer join we have. for this, we use the ‘right join’ keyword inside the query to get the result. But it does return the record differently; let understand this, This basically returns all the records from the second table, that is, the right table, with the matching record found in the left table or the first table. Let’s understand this by a simple diagram for better clarity see below;

Diagram:

Image3

syntax:

SELECT emp.FirstName, emp.LastName, emp.notes, ord.OrderID
FROM Orders as ord
RIGHT OUTER JOIN Employees as emp
ON ord.EmployeeID = emp.EmployeeID;

Output:

output 5

iii) Full outer join: As the name suggests, it returns all the records from both the tables, whether there is a match or not. That means it will be the Cartesian product for both the tables; let’s understand them by the use of the below diagram for better understanding see below;

Diagram:

Image4

Syntax:

SELECT emp.FirstName, emp.LastName, emp.notes, ord.OrderID
FROM Orders as ord
FULL OUTER JOIN Employees as emp
ON ord.EmployeeID = emp.EmployeeID;

Output:

output 6

Conclusion – dbms join

We have covered all the types of joins present in the dbms, which helps us get the record from multiple tables. Also, we have seen joins that return records from either of the tables match the other tables. This is easy to understand by the developers, readable and maintainable, with a lot of online support.

Recommended Articles

We hope that this EDUCBA information on “dbms join” was beneficial to you. You can view EDUCBA’s recommended articles for more information.

  1. DBMS Features
  2. DBMS Components
  3. DBMS_Scheduler
  4. Checkpoint in DBMS

Primary Sidebar

Footer

Follow us!
  • EDUCBA FacebookEDUCBA TwitterEDUCBA LinkedINEDUCBA Instagram
  • EDUCBA YoutubeEDUCBA CourseraEDUCBA Udemy
APPS
EDUCBA Android AppEDUCBA iOS App
Blog
  • Blog
  • Free Tutorials
  • About us
  • Contact us
  • Log in
Courses
  • Enterprise Solutions
  • Free Courses
  • Explore Programs
  • All Courses
  • All in One Bundles
  • Sign up
Email
  • [email protected]

ISO 10004:2018 & ISO 9001:2015 Certified

© 2025 - EDUCBA. ALL RIGHTS RESERVED. THE CERTIFICATION NAMES ARE THE TRADEMARKS OF THEIR RESPECTIVE OWNERS.

EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you

EDUCBA
Free Data Science Course

Hadoop, Data Science, Statistics & others

By continuing above step, you agree to our Terms of Use and Privacy Policy.
*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA

*Please provide your correct email id. Login details for this Free course will be emailed to you
EDUCBA Login

Forgot Password?

Loading . . .
Quiz
Question:

Answer:

Quiz Result
Total QuestionsCorrect AnswersWrong AnswersPercentage

Explore 1000+ varieties of Mock tests View more

🚀 Limited Time Offer! - ENROLL NOW