SlideShare a Scribd company logo
 types of SQL Joins
Prepared by;
name en.number
• Vikram rajpurohit 140500116033
• Taxak mistery 140500116016
• Paras patel 140500116024
SQL Joins
SQL joins are used to get data from two or more
tables bases on relationship between some of the
columns in tables.
In most of the cases we will use primary key of
first table and foreign key of secondary table to
get data from tables
TYPES OF JOIN
Tables for examples
EMPNO ENAME JOB MGR DEPTNO
111 Ramesh Analyst 444 10
222 Khilan Clerk 333 20
333 Kaushik Manager 111 10
444 Chaitali engineer 222 40
DEPTNO DNAME LOC
10 INVENTORY HYDERABAD
20 FINANCE BANGALORE
30 HR MUMBAI
INNER JOIN OR EQUIJOIN
clause is used to combine rows from two or more tables, based on a
common field between them.
INNER JOIN creates a new result table by combining column values of
two tables (table1 and table2) based upon the join-condition.
Keyword used is INNER JOIN or simply JOIN.
INNER JOIN OR EQUIJOIN
Syntax SELECT table1.column1, table2.column2...
FROM table1 INNER JOIN table2 ON
table1.common_field = table2.common_field;
SELECT emp.ename,emp.job,dept.dname,dept.loc from EMPLOYYE emp
INNER JOIN DEPARTMENT dept ON emp.deptno = dept.deptno;
Result……
ENAME JOB DNAME LOC
Ramesh Analyst INVENTORY HYDERABAD
Khilan Clerk FINANCE BANGALORE
Kaushik Manager INVENTORY HYDERABAD
Left Join/Left Outer Join
LEFT JOIN returns all rows from the left table (table1),
even if there are no matches in the right table(table2).
If there are no matches found in right table the result is
null in the right table.
Keyword used is LEFT JOIN.
Left Join Continuation…
Syntax  SELECT table1.column1, table2.column2... FROM table1
LEFT JOIN table2 ON table1.common_field =
table2.common_field;
SELECT emp.ename,emp.job,dept.dname,dept.loc from EMPLOYYE emp
LEFT JOIN DEPARTMENT dept ON emp.deptno = dept.deptno;
OR
SELECT emp.ename,emp.job,dept.dname,dept.loc from EMPLOYYE emp ,
DEPARTMENT dept WHERE emp.deptno(+) = dept.deptno;
ENAME JOB DNAME LOC
Ramesh Analyst INVENTORY HYDERABAD
Khilan Clerk FINANCE BANGALORE
Kaushik Manager INVENTORY HYDERABAD
Chaitali engineer NULL NULL
Right Join/Right Outer Join
RIGHT JOIN returns all rows from the right table (table2),
even if there are no matches in the left table(table1).
If there are no matched found in let table the result is null
in the left table.
Keyword used is RIGHT JOIN.
Right Join Continuation…
Syntax  SELECT table1.column1, table2.column2... FROM table1
RIGHT JOIN table2 ON table1.common_field =
table2.common_field;
SELECT emp.ename,emp.job,dept.dname,dept.loc from EMPLOYYE emp
RIGHT JOIN DEPARTMENT dept ON emp.deptno = dept.deptno;
OR
SELECT emp.ename,emp.job,dept.dname,dept.loc from EMPLOYYE emp,
DEPARTMENT dept WHERE emp.deptno = dept.deptno(+);
ENAME JOB DNAME LOC
Ramesh Analyst INVENTORY HYDERABAD
Khilan Clerk FINANCE BANGALORE
Kaushik Manager INVENTORY HYDERABAD
NULL NULL HR MUMBAI
Full Join
The SQL FULL JOIN combines the results of both left and
right outer joins.
The joined table will contain all records from both tables,
and fill in NULLs for missing matches on either side.
Keyword used is FULL JOIN. In some data bases it is also
known as FULL OUTER JOIN.
Full Join Continuation…
Syntax  SELECT table1.column1, table2.column2... FROM table1
FULL JOIN table2 ON table1.common_field =
table2.common_field;
SELECT emp.ename,emp.job,dept.dname,dept.loc from EMPLOYYE emp
FULL JOIN DEPARTMENT dept ON emp.deptno = dept.deptno;
ENAME JOB DNAME LOC
Ramesh Analyst INVENTORY HYDERABAD
Khilan Clerk FINANCE BANGALORE
Kaushik Manager INVENTORY HYDERABAD
NULL NULL HR MUMBAI
Chaitali engineer NULL NULL
Self Join
SELF JOIN is used to join a table to itself as if the
table were two tables
Syntax  SELECT a.column_name, b.column_name... FROM
table1 a, table1 b WHERE a.common_field = b.common_field;
Self Join Continuation….
SELECT emp1.ename, emp1.job, emp2.ename as
manager FROM EMPLOYEE emp1, EMPLOYEE
emp2 where emp1.mgr = emp2.empno;
ENAME JOB MANAGER
Ramesh Analyst Chaitali
Khilan Clerk Kaushik
Kaushik Manager Ramesh
Chaitali engineer Khilan
 types of SQL Joins

More Related Content

PPTX
Sql joins inner join self join outer joins
PPTX
Oracle: Joins
PPTX
SQL JOIN
PPT
Join sql
PPT
Types Of Join In Sql Server - Join With Example In Sql Server
PPTX
MS Sql Server: Joining Databases
PPTX
Joins And Its Types
Sql joins inner join self join outer joins
Oracle: Joins
SQL JOIN
Join sql
Types Of Join In Sql Server - Join With Example In Sql Server
MS Sql Server: Joining Databases
Joins And Its Types

What's hot (20)

PPTX
PPT
Sql join
PPTX
Using Excel Functions
PPTX
SQL JOINS- Reena P V
PPTX
Sql joins
PPTX
10 Excel Formulas that will help you in any Job
PPTX
PPTX
joins in database
PPTX
Mastering Excel Formulas and Functions
PPTX
VLOOKUP HLOOKUP INDEX MATCH
PPTX
How to use Hlookup find an exact match
PPTX
Formula in MS Excel
PPTX
Sql joins
PPTX
Excel basics for everyday use part three
PPT
Microsoft Excel VLOOKUP Function
PDF
Excel functions formulas
PPT
Lesson 2.1 what is a function
PDF
On if,countif,countifs,sumif,countifs,lookup,v lookup,index,match
PDF
VLOOKUP Function - Marelen Talavera - Vivacious Analytic
PPTX
How to use vlookup in MS Excel
Sql join
Using Excel Functions
SQL JOINS- Reena P V
Sql joins
10 Excel Formulas that will help you in any Job
joins in database
Mastering Excel Formulas and Functions
VLOOKUP HLOOKUP INDEX MATCH
How to use Hlookup find an exact match
Formula in MS Excel
Sql joins
Excel basics for everyday use part three
Microsoft Excel VLOOKUP Function
Excel functions formulas
Lesson 2.1 what is a function
On if,countif,countifs,sumif,countifs,lookup,v lookup,index,match
VLOOKUP Function - Marelen Talavera - Vivacious Analytic
How to use vlookup in MS Excel
Ad

Similar to types of SQL Joins (20)

PDF
Advance database system(part 8)
PPTX
Presentation of Joins In Database
PPT
PPTX
Lab4 join - all types listed
PPTX
PDF
SQL JOINS
PPTX
joins dbms.pptx
PPTX
Querying_with_T-SQL_-_03 (1).pptx
PPTX
Querying_with_T-SQL_-_03.pptx
PDF
3)12th_L8_Join-Set-Operations.pdf
PPTX
Joins.pptxjjbmmmnnnnnjjjxrhjfluflurulrdudlu
PPT
joins IN DATA BASE MANAGEMENT SYSTEMSppt
PPTX
V19 join method-c
PPT
Joins.ppt
PPTX
Joins (A JOIN clause is used to combine rows from two or more tables, based o...
PDF
Joins in databases
PPTX
SQL_JOIN ALL TYPE OF JOINS OF MYSQL.PPTX
PPTX
PRESENTATION........................pptx
PPTX
MS SQLSERVER:Joining Databases
Advance database system(part 8)
Presentation of Joins In Database
Lab4 join - all types listed
SQL JOINS
joins dbms.pptx
Querying_with_T-SQL_-_03 (1).pptx
Querying_with_T-SQL_-_03.pptx
3)12th_L8_Join-Set-Operations.pdf
Joins.pptxjjbmmmnnnnnjjjxrhjfluflurulrdudlu
joins IN DATA BASE MANAGEMENT SYSTEMSppt
V19 join method-c
Joins.ppt
Joins (A JOIN clause is used to combine rows from two or more tables, based o...
Joins in databases
SQL_JOIN ALL TYPE OF JOINS OF MYSQL.PPTX
PRESENTATION........................pptx
MS SQLSERVER:Joining Databases
Ad

More from vikram rajpurohit (6)

PPTX
Factors of Production (economics)
PPT
encoder and decoder in digital electronics
PPT
INTRODUCTION TO ECONOMICS(Microeconomics vs. Macroeconomics)
PPT
FUNCTIONS OF MANAGEMENT
PPTX
Circuit protection devices
PPTX
Circuit protection devices perfect ppt
Factors of Production (economics)
encoder and decoder in digital electronics
INTRODUCTION TO ECONOMICS(Microeconomics vs. Macroeconomics)
FUNCTIONS OF MANAGEMENT
Circuit protection devices
Circuit protection devices perfect ppt

Recently uploaded (20)

PPTX
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
PPTX
Welding lecture in detail for understanding
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PDF
R24 SURVEYING LAB MANUAL for civil enggi
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPT
Mechanical Engineering MATERIALS Selection
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPT
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
PDF
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PPTX
web development for engineering and engineering
DOCX
573137875-Attendance-Management-System-original
PPTX
additive manufacturing of ss316l using mig welding
PDF
Digital Logic Computer Design lecture notes
PDF
Model Code of Practice - Construction Work - 21102022 .pdf
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
Infosys Presentation by1.Riyan Bagwan 2.Samadhan Naiknavare 3.Gaurav Shinde 4...
Welding lecture in detail for understanding
Operating System & Kernel Study Guide-1 - converted.pdf
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
R24 SURVEYING LAB MANUAL for civil enggi
CH1 Production IntroductoryConcepts.pptx
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Mechanical Engineering MATERIALS Selection
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
CRASH COURSE IN ALTERNATIVE PLUMBING CLASS
July 2025 - Top 10 Read Articles in International Journal of Software Enginee...
CYBER-CRIMES AND SECURITY A guide to understanding
web development for engineering and engineering
573137875-Attendance-Management-System-original
additive manufacturing of ss316l using mig welding
Digital Logic Computer Design lecture notes
Model Code of Practice - Construction Work - 21102022 .pdf
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
M Tech Sem 1 Civil Engineering Environmental Sciences.pptx
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT

types of SQL Joins

  • 2. Prepared by; name en.number • Vikram rajpurohit 140500116033 • Taxak mistery 140500116016 • Paras patel 140500116024
  • 3. SQL Joins SQL joins are used to get data from two or more tables bases on relationship between some of the columns in tables. In most of the cases we will use primary key of first table and foreign key of secondary table to get data from tables
  • 5. Tables for examples EMPNO ENAME JOB MGR DEPTNO 111 Ramesh Analyst 444 10 222 Khilan Clerk 333 20 333 Kaushik Manager 111 10 444 Chaitali engineer 222 40 DEPTNO DNAME LOC 10 INVENTORY HYDERABAD 20 FINANCE BANGALORE 30 HR MUMBAI
  • 6. INNER JOIN OR EQUIJOIN clause is used to combine rows from two or more tables, based on a common field between them. INNER JOIN creates a new result table by combining column values of two tables (table1 and table2) based upon the join-condition. Keyword used is INNER JOIN or simply JOIN.
  • 7. INNER JOIN OR EQUIJOIN Syntax SELECT table1.column1, table2.column2... FROM table1 INNER JOIN table2 ON table1.common_field = table2.common_field; SELECT emp.ename,emp.job,dept.dname,dept.loc from EMPLOYYE emp INNER JOIN DEPARTMENT dept ON emp.deptno = dept.deptno;
  • 8. Result…… ENAME JOB DNAME LOC Ramesh Analyst INVENTORY HYDERABAD Khilan Clerk FINANCE BANGALORE Kaushik Manager INVENTORY HYDERABAD
  • 9. Left Join/Left Outer Join LEFT JOIN returns all rows from the left table (table1), even if there are no matches in the right table(table2). If there are no matches found in right table the result is null in the right table. Keyword used is LEFT JOIN.
  • 10. Left Join Continuation… Syntax  SELECT table1.column1, table2.column2... FROM table1 LEFT JOIN table2 ON table1.common_field = table2.common_field; SELECT emp.ename,emp.job,dept.dname,dept.loc from EMPLOYYE emp LEFT JOIN DEPARTMENT dept ON emp.deptno = dept.deptno; OR SELECT emp.ename,emp.job,dept.dname,dept.loc from EMPLOYYE emp , DEPARTMENT dept WHERE emp.deptno(+) = dept.deptno; ENAME JOB DNAME LOC Ramesh Analyst INVENTORY HYDERABAD Khilan Clerk FINANCE BANGALORE Kaushik Manager INVENTORY HYDERABAD Chaitali engineer NULL NULL
  • 11. Right Join/Right Outer Join RIGHT JOIN returns all rows from the right table (table2), even if there are no matches in the left table(table1). If there are no matched found in let table the result is null in the left table. Keyword used is RIGHT JOIN.
  • 12. Right Join Continuation… Syntax  SELECT table1.column1, table2.column2... FROM table1 RIGHT JOIN table2 ON table1.common_field = table2.common_field; SELECT emp.ename,emp.job,dept.dname,dept.loc from EMPLOYYE emp RIGHT JOIN DEPARTMENT dept ON emp.deptno = dept.deptno; OR SELECT emp.ename,emp.job,dept.dname,dept.loc from EMPLOYYE emp, DEPARTMENT dept WHERE emp.deptno = dept.deptno(+); ENAME JOB DNAME LOC Ramesh Analyst INVENTORY HYDERABAD Khilan Clerk FINANCE BANGALORE Kaushik Manager INVENTORY HYDERABAD NULL NULL HR MUMBAI
  • 13. Full Join The SQL FULL JOIN combines the results of both left and right outer joins. The joined table will contain all records from both tables, and fill in NULLs for missing matches on either side. Keyword used is FULL JOIN. In some data bases it is also known as FULL OUTER JOIN.
  • 14. Full Join Continuation… Syntax  SELECT table1.column1, table2.column2... FROM table1 FULL JOIN table2 ON table1.common_field = table2.common_field; SELECT emp.ename,emp.job,dept.dname,dept.loc from EMPLOYYE emp FULL JOIN DEPARTMENT dept ON emp.deptno = dept.deptno; ENAME JOB DNAME LOC Ramesh Analyst INVENTORY HYDERABAD Khilan Clerk FINANCE BANGALORE Kaushik Manager INVENTORY HYDERABAD NULL NULL HR MUMBAI Chaitali engineer NULL NULL
  • 15. Self Join SELF JOIN is used to join a table to itself as if the table were two tables Syntax  SELECT a.column_name, b.column_name... FROM table1 a, table1 b WHERE a.common_field = b.common_field;
  • 16. Self Join Continuation…. SELECT emp1.ename, emp1.job, emp2.ename as manager FROM EMPLOYEE emp1, EMPLOYEE emp2 where emp1.mgr = emp2.empno; ENAME JOB MANAGER Ramesh Analyst Chaitali Khilan Clerk Kaushik Kaushik Manager Ramesh Chaitali engineer Khilan