SlideShare a Scribd company logo
1 of 17
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

What's hot

Using Excel Functions
Using Excel FunctionsUsing Excel Functions
Using Excel FunctionsGautam Gupta
 
10 Excel Formulas that will help you in any Job
10 Excel Formulas that will help you in any Job10 Excel Formulas that will help you in any Job
10 Excel Formulas that will help you in any JobHitesh Biyani
 
VLOOKUP HLOOKUP INDEX MATCH
VLOOKUP HLOOKUP INDEX MATCHVLOOKUP HLOOKUP INDEX MATCH
VLOOKUP HLOOKUP INDEX MATCHMridul Bansal
 
How to use Hlookup find an exact match
How to use Hlookup find an exact match How to use Hlookup find an exact match
How to use Hlookup find an exact match Excel Advise
 
Excel basics for everyday use part three
Excel basics for everyday use part threeExcel basics for everyday use part three
Excel basics for everyday use part threeKevin McLogan
 
Microsoft Excel VLOOKUP Function
Microsoft Excel VLOOKUP FunctionMicrosoft Excel VLOOKUP Function
Microsoft Excel VLOOKUP FunctionExcel
 
Excel functions formulas
Excel functions formulasExcel functions formulas
Excel functions formulasLearnIT@UD
 
Lesson 2.1 what is a function
Lesson 2.1    what is a functionLesson 2.1    what is a function
Lesson 2.1 what is a functionDreams4school
 
On if,countif,countifs,sumif,countifs,lookup,v lookup,index,match
On if,countif,countifs,sumif,countifs,lookup,v lookup,index,matchOn if,countif,countifs,sumif,countifs,lookup,v lookup,index,match
On if,countif,countifs,sumif,countifs,lookup,v lookup,index,matchRakesh Sah
 
VLOOKUP Function - Marelen Talavera - Vivacious Analytic
VLOOKUP Function - Marelen Talavera - Vivacious AnalyticVLOOKUP Function - Marelen Talavera - Vivacious Analytic
VLOOKUP Function - Marelen Talavera - Vivacious AnalyticMaria Elena Acdol-Talavera
 
How to use vlookup in MS Excel
How to use vlookup in MS ExcelHow to use vlookup in MS Excel
How to use vlookup in MS ExcelJaspal Singh
 

What's hot (20)

Joins
JoinsJoins
Joins
 
Sql join
Sql  joinSql  join
Sql join
 
Using Excel Functions
Using Excel FunctionsUsing Excel Functions
Using Excel Functions
 
SQL JOINS- Reena P V
SQL JOINS- Reena P VSQL JOINS- Reena P V
SQL JOINS- Reena P V
 
Sql joins
Sql joinsSql joins
Sql joins
 
10 Excel Formulas that will help you in any Job
10 Excel Formulas that will help you in any Job10 Excel Formulas that will help you in any Job
10 Excel Formulas that will help you in any Job
 
Join
JoinJoin
Join
 
joins in database
 joins in database joins in database
joins in database
 
Mastering Excel Formulas and Functions
Mastering Excel Formulas and FunctionsMastering Excel Formulas and Functions
Mastering Excel Formulas and Functions
 
VLOOKUP HLOOKUP INDEX MATCH
VLOOKUP HLOOKUP INDEX MATCHVLOOKUP HLOOKUP INDEX MATCH
VLOOKUP HLOOKUP INDEX MATCH
 
How to use Hlookup find an exact match
How to use Hlookup find an exact match How to use Hlookup find an exact match
How to use Hlookup find an exact match
 
Formula in MS Excel
Formula in MS ExcelFormula in MS Excel
Formula in MS Excel
 
Sql joins
Sql joinsSql joins
Sql joins
 
Excel basics for everyday use part three
Excel basics for everyday use part threeExcel basics for everyday use part three
Excel basics for everyday use part three
 
Microsoft Excel VLOOKUP Function
Microsoft Excel VLOOKUP FunctionMicrosoft Excel VLOOKUP Function
Microsoft Excel VLOOKUP Function
 
Excel functions formulas
Excel functions formulasExcel functions formulas
Excel functions formulas
 
Lesson 2.1 what is a function
Lesson 2.1    what is a functionLesson 2.1    what is a function
Lesson 2.1 what is a function
 
On if,countif,countifs,sumif,countifs,lookup,v lookup,index,match
On if,countif,countifs,sumif,countifs,lookup,v lookup,index,matchOn if,countif,countifs,sumif,countifs,lookup,v lookup,index,match
On if,countif,countifs,sumif,countifs,lookup,v lookup,index,match
 
VLOOKUP Function - Marelen Talavera - Vivacious Analytic
VLOOKUP Function - Marelen Talavera - Vivacious AnalyticVLOOKUP Function - Marelen Talavera - Vivacious Analytic
VLOOKUP Function - Marelen Talavera - Vivacious Analytic
 
How to use vlookup in MS Excel
How to use vlookup in MS ExcelHow to use vlookup in MS Excel
How to use vlookup in MS Excel
 

Similar to types of SQL Joins

joins and subqueries in big data analysis
joins and subqueries in big data analysisjoins and subqueries in big data analysis
joins and subqueries in big data analysisSanSan149
 
Join in SQL - Inner, Self, Outer Join
Join in SQL - Inner, Self, Outer JoinJoin in SQL - Inner, Self, Outer Join
Join in SQL - Inner, Self, Outer JoinSouma Maiti
 
Assignment 4
Assignment 4Assignment 4
Assignment 4SneaK3
 
Sql(structured query language)
Sql(structured query language)Sql(structured query language)
Sql(structured query language)Ishucs
 
MS SQL SERVER: Joining Databases
MS SQL SERVER: Joining DatabasesMS SQL SERVER: Joining Databases
MS SQL SERVER: Joining Databasessqlserver content
 
MS SQLSERVER:Joining Databases
MS SQLSERVER:Joining DatabasesMS SQLSERVER:Joining Databases
MS SQLSERVER:Joining Databasessqlserver content
 
Sql server ___________session_11-12(joins)
Sql server  ___________session_11-12(joins)Sql server  ___________session_11-12(joins)
Sql server ___________session_11-12(joins)Ehtisham Ali
 
Lesson 6 - Relational Algebra.pdf
Lesson 6 - Relational Algebra.pdfLesson 6 - Relational Algebra.pdf
Lesson 6 - Relational Algebra.pdfHasankaWijesinghe1
 
SQL Joins.pptx
SQL Joins.pptxSQL Joins.pptx
SQL Joins.pptxAnkit Rai
 

Similar to types of SQL Joins (20)

joins and subqueries in big data analysis
joins and subqueries in big data analysisjoins and subqueries in big data analysis
joins and subqueries in big data analysis
 
Joins in SQL
Joins in SQLJoins in SQL
Joins in SQL
 
V19 join method-c
V19 join method-cV19 join method-c
V19 join method-c
 
Join in SQL - Inner, Self, Outer Join
Join in SQL - Inner, Self, Outer JoinJoin in SQL - Inner, Self, Outer Join
Join in SQL - Inner, Self, Outer Join
 
Assignment 4
Assignment 4Assignment 4
Assignment 4
 
JOINS.pptx
JOINS.pptxJOINS.pptx
JOINS.pptx
 
Sql(structured query language)
Sql(structured query language)Sql(structured query language)
Sql(structured query language)
 
database .pptx
database .pptxdatabase .pptx
database .pptx
 
Lab4 join - all types listed
Lab4   join - all types listedLab4   join - all types listed
Lab4 join - all types listed
 
MS SQL SERVER: Joining Databases
MS SQL SERVER: Joining DatabasesMS SQL SERVER: Joining Databases
MS SQL SERVER: Joining Databases
 
MS SQLSERVER:Joining Databases
MS SQLSERVER:Joining DatabasesMS SQLSERVER:Joining Databases
MS SQLSERVER:Joining Databases
 
Joining
JoiningJoining
Joining
 
Oracle: Joins
Oracle: JoinsOracle: Joins
Oracle: Joins
 
SQL JOINS
SQL JOINSSQL JOINS
SQL JOINS
 
Sql server ___________session_11-12(joins)
Sql server  ___________session_11-12(joins)Sql server  ___________session_11-12(joins)
Sql server ___________session_11-12(joins)
 
SQL JOIN.pptx
SQL JOIN.pptxSQL JOIN.pptx
SQL JOIN.pptx
 
Les04
Les04Les04
Les04
 
Join query
Join queryJoin query
Join query
 
Lesson 6 - Relational Algebra.pdf
Lesson 6 - Relational Algebra.pdfLesson 6 - Relational Algebra.pdf
Lesson 6 - Relational Algebra.pdf
 
SQL Joins.pptx
SQL Joins.pptxSQL Joins.pptx
SQL Joins.pptx
 

More from vikram rajpurohit

Factors of Production (economics)
Factors of Production (economics)Factors of Production (economics)
Factors of Production (economics)vikram rajpurohit
 
encoder and decoder in digital electronics
encoder and decoder in digital electronicsencoder and decoder in digital electronics
encoder and decoder in digital electronicsvikram rajpurohit
 
INTRODUCTION TO ECONOMICS(Microeconomics vs. Macroeconomics)
INTRODUCTION TO ECONOMICS(Microeconomics vs. Macroeconomics)INTRODUCTION TO ECONOMICS(Microeconomics vs. Macroeconomics)
INTRODUCTION TO ECONOMICS(Microeconomics vs. Macroeconomics)vikram rajpurohit
 
Circuit protection devices perfect ppt
Circuit protection devices perfect ppt Circuit protection devices perfect ppt
Circuit protection devices perfect ppt vikram rajpurohit
 

More from vikram rajpurohit (6)

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

Recently uploaded

SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxupamatechverse
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...ranjana rawat
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Dr.Costas Sachpazis
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingrakeshbaidya232001
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performancesivaprakash250
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 

Recently uploaded (20)

SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
Introduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptxIntroduction to IEEE STANDARDS and its different types.pptx
Introduction to IEEE STANDARDS and its different types.pptx
 
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
The Most Attractive Pune Call Girls Budhwar Peth 8250192130 Will You Miss Thi...
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
Structural Analysis and Design of Foundations: A Comprehensive Handbook for S...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Porous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writingPorous Ceramics seminar and technical writing
Porous Ceramics seminar and technical writing
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
UNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its PerformanceUNIT - IV - Air Compressors and its Performance
UNIT - IV - Air Compressors and its Performance
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
Call Girls in Nagpur Suman Call 7001035870 Meet With Nagpur Escorts
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 

types of SQL Joins

  • 1.
  • 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