SlideShare a Scribd company logo
Joins
Presented by,
S.VIGNESHWARAN
Join in SQL
• SQL Join is used to fetch data from two or more
tables, which is joined to appear as single set of
data.
• SQL Join is used for combining column from two
or more tables by using values common to both
tables.
• Join Keyword is used in SQL queries for joining
two or more tables.
• Minimum required condition for joining table, is
(n-1) where n, is number of tables.
• A table can also join to itself known as, Self Join.
Types of Join
Inner
Outer
Left
Right
INNER Join or EQUI Join
• This is a simple JOIN in which the result is based on
matched data as per the equality condition specified in
the query.
Syntax
SELECT column-name-list
from table-name1
INNER JOIN
table-name2
WHERE table-name1.column-name = table-
name2.column-name;
SELECT * from class, classinfo where
class.id = classinfo.id;
ID NAME
1 ABHI
2 ADAM
3 ALEX
4 ANU
ID Address
1 DELHI
2 MUMBAI
3 CHENNAI
ID NAME ID Address
1 ABHI 1 DELHI
2 ADAM 2 MUMBAI
3 ALEX 3 CHENNAI
Cross JOIN or Cartesian Product
• This type of JOIN returns the Cartesian product of rows
of from the tables in Join. It will return a table which
consists of records which combines each row from the
first table with each row of the second table.
Cross JOIN Syntax is,
SELECT column-name-list
from table-name1
CROSS JOIN
table-name2;
SELECT * from class, cross JOIN classinfo;
class classinfo
ID NAME
1 ABHI
2 ADAM
4 ALEX
ID Address
1 DELHI
2 MUMBAI
3 CHENNAI
ID NAME ID Address
1 ABHI 1 DELHI
2 ADAM 1 DELHI
4 ALEX 1 DELHI
1 ABHI 2 MUMBAI
2 ADAM 2 MUMBAI
4 ALEX 2 MUMBAI
1 ABHI 3 CHENNAI
2 ADAM 3 CHENNAI
4 ALEX 3 CHENNAI
Natural JOIN
• Natural Join is a type of Inner join which is
based on column having same name and same
data type present in both the tables to be
joined.
• Syntax
SELECT *
from table-name1
NATURAL JOIN
table-name2;
SELECT * from class NATURAL JOIN classinfo;
class classinfo
ID NAME
1 ABHI
2 ADAM
3 ALEX
4 ANU
ID Address
1 DELHI
2 MUMBAI
3 CHENNAI
ID NAME Address
1 ABHI DELHI
2 ADAM MUMBAI
3 ALEX CHENNAI
Outer JOIN
• Outer Join is based on both matched and
unmatched data.
Left Outer Join
Right Outer Join
Full Outer Join
Left Outer Join
• The left outer join returns a result table with the
matched data of two tables then remaining rows
of the left table and null for the right table's
column.
Syntax
SELECT column-name-list
from table-name1
LEFT OUTER JOIN
table-name2
on table-name1.column-name = table-name2.column-name;
SELECT * FROM class LEFT OUTER JOIN classinfo ON
(class.id=classinfo.id);
ID NAME
1 ABHI
2 ADAM
3 ALEX
4 ANU
5 ASHISH
ID NAME ID ADDRESS
1 ABHI 1 DELHI
2 ADAM 2 MUMBAI
3 ALEX 3 CHENNAI
4 ANU NULL NULL
5 ASHISH NULL NULL
ID Address
1 DELHI
2 MUMBAI
3 CHENNAI
7 NOIDA
8 PANIPAT
Right Outer Join
• The right outer join returns a result table with the
matched data of two tables then remaining rows
of the right table and null for the left table's
columns.
Syntax
select column-name-list
from table-name1
RIGHT OUTER JOIN
table-name2
on table-name1.column-name = table-name2.column-name;
select * from class right outer join
classinfo on (class.id=classinfo.id);
ID NAME
1 ABHI
2 ADAM
3 ALEX
4 ANU
5 ASHISH
ID ADDRESS
1 DELHI
2 MUMBAI
3 CHENNAI
7 NOIDA
8 PANIPAT
ID NAME ID ADDRESS
1 ABHI 1 DELHI
2 ADAM 2 MUMBAI
3 ALEX 3 CHENNAI
NULL NULL 7 NOIDA
NULL NULL 8 PANIPAT
Full Outer Join
• The full outer join returns a result table with the
matched data of two table then remaining rows
of both left table and then the right table.
Syntax
select column-name-list
from table-name1
FULL OUTER JOIN
table-name2
on table-name1.column-name = table-name2.column-name;
SELECT * FROM class FULL OUTER JOIN classinfo on
(class.id=classinfo.id);
ID NAME
1 ABHI
2 ADAM
3 ALEX
4 ANU
5 ASHISH
ID ADDRESS
1 DELHI
2 MUMBAI
3 CHENNAI
7 NOIDA
8 PANIPAT
ID NAME ID ADDRESS
1 ABHI 1 DELHI
2 ADAM 2 MUMBAI
3 ALEX 3 CHENNAI
4 ANU NULL NULL
5 ASHISH NULL NULL
Ad

More Related Content

What's hot (20)

SQL(DDL & DML)
SQL(DDL & DML)SQL(DDL & DML)
SQL(DDL & DML)
Sharad Dubey
 
SQL commands
SQL commandsSQL commands
SQL commands
GirdharRatne
 
PL/SQL - CURSORS
PL/SQL - CURSORSPL/SQL - CURSORS
PL/SQL - CURSORS
IshaRana14
 
Relational model
Relational modelRelational model
Relational model
Dabbal Singh Mahara
 
joins in database
 joins in database joins in database
joins in database
Sultan Arshad
 
SQL Views
SQL ViewsSQL Views
SQL Views
baabtra.com - No. 1 supplier of quality freshers
 
Set operators
Set  operatorsSet  operators
Set operators
Manuel S. Enverga University Foundation
 
SQL Queries Information
SQL Queries InformationSQL Queries Information
SQL Queries Information
Nishant Munjal
 
database language ppt.pptx
database language ppt.pptxdatabase language ppt.pptx
database language ppt.pptx
Anusha sivakumar
 
SQL JOINS
SQL JOINSSQL JOINS
SQL JOINS
Swapnali Pawar
 
SQL Functions
SQL FunctionsSQL Functions
SQL Functions
ammarbrohi
 
Aggregate function
Aggregate functionAggregate function
Aggregate function
Rayhan Chowdhury
 
Stored procedure
Stored procedureStored procedure
Stored procedure
baabtra.com - No. 1 supplier of quality freshers
 
DBMS Keys
DBMS KeysDBMS Keys
DBMS Keys
Tarun Maheshwari
 
Relational Algebra,Types of join
Relational Algebra,Types of joinRelational Algebra,Types of join
Relational Algebra,Types of join
raj upadhyay
 
Aggregate functions
Aggregate functionsAggregate functions
Aggregate functions
sinhacp
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
madhav bansal
 
Dbms 14: Relational Calculus
Dbms 14: Relational CalculusDbms 14: Relational Calculus
Dbms 14: Relational Calculus
Amiya9439793168
 
Normalization in DBMS
Normalization in DBMSNormalization in DBMS
Normalization in DBMS
Hitesh Mohapatra
 
Types Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql ServerTypes Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql Server
programmings guru
 

Viewers also liked (8)

Inner Join In Ms Access
Inner Join In Ms AccessInner Join In Ms Access
Inner Join In Ms Access
Talesun Solar USA Ltd.
 
Join
JoinJoin
Join
Kanchana Rani G
 
SQL Joins and Query Optimization
SQL Joins and Query OptimizationSQL Joins and Query Optimization
SQL Joins and Query Optimization
Brian Gallagher
 
Sql joins
Sql joinsSql joins
Sql joins
Gaurav Dhanwant
 
Chapter 7 - Deadlocks
Chapter 7 - DeadlocksChapter 7 - Deadlocks
Chapter 7 - Deadlocks
Wayne Jones Jnr
 
Mapreduce Algorithms
Mapreduce AlgorithmsMapreduce Algorithms
Mapreduce Algorithms
Amund Tveit
 
Operating System Deadlock Galvin
Operating System  Deadlock GalvinOperating System  Deadlock Galvin
Operating System Deadlock Galvin
Sonali Chauhan
 
Ch8
Ch8Ch8
Ch8
Bilal Arshad
 
Ad

Similar to Joins in SQL (20)

joins IN DATA BASE MANAGEMENT SYSTEMSppt
joins IN DATA BASE MANAGEMENT SYSTEMSpptjoins IN DATA BASE MANAGEMENT SYSTEMSppt
joins IN DATA BASE MANAGEMENT SYSTEMSppt
Uma Kakarlapudi
 
Join query
Join queryJoin query
Join query
Waqar Ali
 
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
Souma Maiti
 
Joins and unions
Joins and unionsJoins and unions
Joins and unions
baabtra.com - No. 1 supplier of quality freshers
 
Kailas Manoj SQL Joins.pptxhgvhhhbjgjjjjjgjgjjj
Kailas Manoj SQL Joins.pptxhgvhhhbjgjjjjjgjgjjjKailas Manoj SQL Joins.pptxhgvhhhbjgjjjjjgjgjjj
Kailas Manoj SQL Joins.pptxhgvhhhbjgjjjjjgjgjjj
kailasmanoj
 
Kailas Manoj SQL Joins.pdfhvhggjbhbbjbjbbjbj
Kailas Manoj SQL Joins.pdfhvhggjbhbbjbjbbjbjKailas Manoj SQL Joins.pdfhvhggjbhbbjbjbbjbj
Kailas Manoj SQL Joins.pdfhvhggjbhbbjbjbbjbj
kailasmanoj
 
Relational algebra
Relational algebraRelational algebra
Relational algebra
Joshi Vinay
 
SQL JOIN.pptx
SQL JOIN.pptxSQL JOIN.pptx
SQL JOIN.pptx
johnwick814916
 
Joins and Views.pptx
Joins and Views.pptxJoins and Views.pptx
Joins and Views.pptx
SangitaKabi
 
Sql
SqlSql
Sql
RittikaBaksi
 
sqljoins-220527115331-828e9932 (dee1).pptx
sqljoins-220527115331-828e9932 (dee1).pptxsqljoins-220527115331-828e9932 (dee1).pptx
sqljoins-220527115331-828e9932 (dee1).pptx
kailasmanoj
 
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
SanSan149
 
sqlyyybdbyehduheufhuehfuheuwehfiewifhewihfiehfiwf
sqlyyybdbyehduheufhuehfuheuwehfiewifhewihfiehfiwfsqlyyybdbyehduheufhuehfuheuwehfiewifhewihfiehfiwf
sqlyyybdbyehduheufhuehfuheuwehfiewifhewihfiehfiwf
kailasmanoj
 
sql joinsubdjbrjdbjrjnfkjcnkrnfknrkfkrfkrfkrk
sql joinsubdjbrjdbjrjnfkjcnkrnfknrkfkrfkrfkrksql joinsubdjbrjdbjrjnfkjcnkrnfknrkfkrfkrfkrk
sql joinsubdjbrjdbjrjnfkjcnkrnfknrkfkrfkrfkrk
kailasmanoj
 
Joins
JoinsJoins
Joins
Mritunjay Sharma
 
Sql joins final
Sql joins finalSql joins final
Sql joins final
mbadhi
 
Joins in SQL
Joins in SQLJoins in SQL
Joins in SQL
Pooja Dixit
 
Joining
JoiningJoining
Joining
Abrar ali
 
Sql joins
Sql joinsSql joins
Sql joins
LokeshGogia2
 
ADBMS - Joins , Sorting , Distributed Database Systems
ADBMS - Joins , Sorting , Distributed Database SystemsADBMS - Joins , Sorting , Distributed Database Systems
ADBMS - Joins , Sorting , Distributed Database Systems
Joshua Costa
 
joins IN DATA BASE MANAGEMENT SYSTEMSppt
joins IN DATA BASE MANAGEMENT SYSTEMSpptjoins IN DATA BASE MANAGEMENT SYSTEMSppt
joins IN DATA BASE MANAGEMENT SYSTEMSppt
Uma Kakarlapudi
 
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
Souma Maiti
 
Kailas Manoj SQL Joins.pptxhgvhhhbjgjjjjjgjgjjj
Kailas Manoj SQL Joins.pptxhgvhhhbjgjjjjjgjgjjjKailas Manoj SQL Joins.pptxhgvhhhbjgjjjjjgjgjjj
Kailas Manoj SQL Joins.pptxhgvhhhbjgjjjjjgjgjjj
kailasmanoj
 
Kailas Manoj SQL Joins.pdfhvhggjbhbbjbjbbjbj
Kailas Manoj SQL Joins.pdfhvhggjbhbbjbjbbjbjKailas Manoj SQL Joins.pdfhvhggjbhbbjbjbbjbj
Kailas Manoj SQL Joins.pdfhvhggjbhbbjbjbbjbj
kailasmanoj
 
Relational algebra
Relational algebraRelational algebra
Relational algebra
Joshi Vinay
 
Joins and Views.pptx
Joins and Views.pptxJoins and Views.pptx
Joins and Views.pptx
SangitaKabi
 
sqljoins-220527115331-828e9932 (dee1).pptx
sqljoins-220527115331-828e9932 (dee1).pptxsqljoins-220527115331-828e9932 (dee1).pptx
sqljoins-220527115331-828e9932 (dee1).pptx
kailasmanoj
 
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
SanSan149
 
sqlyyybdbyehduheufhuehfuheuwehfiewifhewihfiehfiwf
sqlyyybdbyehduheufhuehfuheuwehfiewifhewihfiehfiwfsqlyyybdbyehduheufhuehfuheuwehfiewifhewihfiehfiwf
sqlyyybdbyehduheufhuehfuheuwehfiewifhewihfiehfiwf
kailasmanoj
 
sql joinsubdjbrjdbjrjnfkjcnkrnfknrkfkrfkrfkrk
sql joinsubdjbrjdbjrjnfkjcnkrnfknrkfkrfkrfkrksql joinsubdjbrjdbjrjnfkjcnkrnfknrkfkrfkrfkrk
sql joinsubdjbrjdbjrjnfkjcnkrnfknrkfkrfkrfkrk
kailasmanoj
 
Sql joins final
Sql joins finalSql joins final
Sql joins final
mbadhi
 
ADBMS - Joins , Sorting , Distributed Database Systems
ADBMS - Joins , Sorting , Distributed Database SystemsADBMS - Joins , Sorting , Distributed Database Systems
ADBMS - Joins , Sorting , Distributed Database Systems
Joshua Costa
 
Ad

Recently uploaded (20)

Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Journal of Soft Computing in Civil Engineering
 
introduction to machine learining for beginers
introduction to machine learining for beginersintroduction to machine learining for beginers
introduction to machine learining for beginers
JoydebSheet
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdffive-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
AdityaSharma944496
 
DSP and MV the Color image processing.ppt
DSP and MV the  Color image processing.pptDSP and MV the  Color image processing.ppt
DSP and MV the Color image processing.ppt
HafizAhamed8
 
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Journal of Soft Computing in Civil Engineering
 
QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)
rccbatchplant
 
railway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forgingrailway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forging
Javad Kadkhodapour
 
Oil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdfOil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdf
M7md3li2
 
IntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdfIntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdf
Luiz Carneiro
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
Reagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptxReagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptx
AlejandroOdio
 
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design ThinkingDT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DhruvChotaliya2
 
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G..."Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
Infopitaara
 
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptxLidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
RishavKumar530754
 
Introduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptxIntroduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptx
AS1920
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
introduction to machine learining for beginers
introduction to machine learining for beginersintroduction to machine learining for beginers
introduction to machine learining for beginers
JoydebSheet
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdffive-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
AdityaSharma944496
 
DSP and MV the Color image processing.ppt
DSP and MV the  Color image processing.pptDSP and MV the  Color image processing.ppt
DSP and MV the Color image processing.ppt
HafizAhamed8
 
QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)QA/QC Manager (Quality management Expert)
QA/QC Manager (Quality management Expert)
rccbatchplant
 
railway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forgingrailway wheels, descaling after reheating and before forging
railway wheels, descaling after reheating and before forging
Javad Kadkhodapour
 
Oil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdfOil-gas_Unconventional oil and gass_reseviours.pdf
Oil-gas_Unconventional oil and gass_reseviours.pdf
M7md3li2
 
IntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdfIntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdf
Luiz Carneiro
 
Smart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptxSmart_Storage_Systems_Production_Engineering.pptx
Smart_Storage_Systems_Production_Engineering.pptx
rushikeshnavghare94
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
Reagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptxReagent dosing (Bredel) presentation.pptx
Reagent dosing (Bredel) presentation.pptx
AlejandroOdio
 
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design ThinkingDT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DhruvChotaliya2
 
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G..."Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...
Infopitaara
 
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptxLidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
Lidar for Autonomous Driving, LiDAR Mapping for Driverless Cars.pptx
RishavKumar530754
 
Introduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptxIntroduction to Zoomlion Earthmoving.pptx
Introduction to Zoomlion Earthmoving.pptx
AS1920
 

Joins in SQL

  • 2. Join in SQL • SQL Join is used to fetch data from two or more tables, which is joined to appear as single set of data. • SQL Join is used for combining column from two or more tables by using values common to both tables. • Join Keyword is used in SQL queries for joining two or more tables. • Minimum required condition for joining table, is (n-1) where n, is number of tables. • A table can also join to itself known as, Self Join.
  • 4. INNER Join or EQUI Join • This is a simple JOIN in which the result is based on matched data as per the equality condition specified in the query. Syntax SELECT column-name-list from table-name1 INNER JOIN table-name2 WHERE table-name1.column-name = table- name2.column-name;
  • 5. SELECT * from class, classinfo where class.id = classinfo.id; ID NAME 1 ABHI 2 ADAM 3 ALEX 4 ANU ID Address 1 DELHI 2 MUMBAI 3 CHENNAI ID NAME ID Address 1 ABHI 1 DELHI 2 ADAM 2 MUMBAI 3 ALEX 3 CHENNAI
  • 6. Cross JOIN or Cartesian Product • This type of JOIN returns the Cartesian product of rows of from the tables in Join. It will return a table which consists of records which combines each row from the first table with each row of the second table. Cross JOIN Syntax is, SELECT column-name-list from table-name1 CROSS JOIN table-name2;
  • 7. SELECT * from class, cross JOIN classinfo; class classinfo ID NAME 1 ABHI 2 ADAM 4 ALEX ID Address 1 DELHI 2 MUMBAI 3 CHENNAI ID NAME ID Address 1 ABHI 1 DELHI 2 ADAM 1 DELHI 4 ALEX 1 DELHI 1 ABHI 2 MUMBAI 2 ADAM 2 MUMBAI 4 ALEX 2 MUMBAI 1 ABHI 3 CHENNAI 2 ADAM 3 CHENNAI 4 ALEX 3 CHENNAI
  • 8. Natural JOIN • Natural Join is a type of Inner join which is based on column having same name and same data type present in both the tables to be joined. • Syntax SELECT * from table-name1 NATURAL JOIN table-name2;
  • 9. SELECT * from class NATURAL JOIN classinfo; class classinfo ID NAME 1 ABHI 2 ADAM 3 ALEX 4 ANU ID Address 1 DELHI 2 MUMBAI 3 CHENNAI ID NAME Address 1 ABHI DELHI 2 ADAM MUMBAI 3 ALEX CHENNAI
  • 10. Outer JOIN • Outer Join is based on both matched and unmatched data. Left Outer Join Right Outer Join Full Outer Join
  • 11. Left Outer Join • The left outer join returns a result table with the matched data of two tables then remaining rows of the left table and null for the right table's column. Syntax SELECT column-name-list from table-name1 LEFT OUTER JOIN table-name2 on table-name1.column-name = table-name2.column-name;
  • 12. SELECT * FROM class LEFT OUTER JOIN classinfo ON (class.id=classinfo.id); ID NAME 1 ABHI 2 ADAM 3 ALEX 4 ANU 5 ASHISH ID NAME ID ADDRESS 1 ABHI 1 DELHI 2 ADAM 2 MUMBAI 3 ALEX 3 CHENNAI 4 ANU NULL NULL 5 ASHISH NULL NULL ID Address 1 DELHI 2 MUMBAI 3 CHENNAI 7 NOIDA 8 PANIPAT
  • 13. Right Outer Join • The right outer join returns a result table with the matched data of two tables then remaining rows of the right table and null for the left table's columns. Syntax select column-name-list from table-name1 RIGHT OUTER JOIN table-name2 on table-name1.column-name = table-name2.column-name;
  • 14. select * from class right outer join classinfo on (class.id=classinfo.id); ID NAME 1 ABHI 2 ADAM 3 ALEX 4 ANU 5 ASHISH ID ADDRESS 1 DELHI 2 MUMBAI 3 CHENNAI 7 NOIDA 8 PANIPAT ID NAME ID ADDRESS 1 ABHI 1 DELHI 2 ADAM 2 MUMBAI 3 ALEX 3 CHENNAI NULL NULL 7 NOIDA NULL NULL 8 PANIPAT
  • 15. Full Outer Join • The full outer join returns a result table with the matched data of two table then remaining rows of both left table and then the right table. Syntax select column-name-list from table-name1 FULL OUTER JOIN table-name2 on table-name1.column-name = table-name2.column-name;
  • 16. SELECT * FROM class FULL OUTER JOIN classinfo on (class.id=classinfo.id); ID NAME 1 ABHI 2 ADAM 3 ALEX 4 ANU 5 ASHISH ID ADDRESS 1 DELHI 2 MUMBAI 3 CHENNAI 7 NOIDA 8 PANIPAT ID NAME ID ADDRESS 1 ABHI 1 DELHI 2 ADAM 2 MUMBAI 3 ALEX 3 CHENNAI 4 ANU NULL NULL 5 ASHISH NULL NULL