SlideShare a Scribd company logo
3
Most read
10
Most read
11
Most read
SQL JOINS
PRESENTED BY
Siddhesh S. Palkar
WHAT IS JOINNING ???
Introduction
 A SQL join clause combines columns from
one or more tables in a relational
database. It creates a set that can be
saved as a table or used as it is.
 A JOIN is a means for combining columns
from one or more tables by using values
common to each.
Type of SQL Joins
Inner Join
Outer Join
Cross Join
Inner Joins
Inner join returns only those records that match in both the tables.
Syntax:
Select * from table 1 INNER JOIN
table 2
ON
Table 1.Column 1=table 2.Column 1
Scenario
EmpID EmpName DepID
1 Siddhesh 3
2 Sumit 4
3 Rakesh 1
4 Omkar 2
5 Shailesh 4
DepID DepName
1 Accounts
2 Sales
3 HR
4 Technical
Tab_Employee Tab_Department
Inner Join ( Example )
Query :
SELECT a.EmpID , a.EmpName , Tab_Department.DepName
FROM Tab_Employee a
INNER JOIN Tab_Department b
ON a.DepID = b.DepID;
Result :
EmpID EmpName DepName
1 Siddhesh HR
2 Sumit Technical
3 Rakesh Accounts
4 Omkar Sales
5 Shailesh Technical
Outer Joins
There are three types of Outer Joins :
 Left Outer Joins
 Right Outer Joins
 Full Outer Joins
Left Outer Joins
Left outer join returns all records/rows from left table and from right table
returns only matched records.
Syntax:
Select * from Table 1
Left Outer Join Table 2
ON
Table 1.Column 1=Table 2.Column 1
Right Outer Joins
Syntax:
Select * from Table 1
Right Outer Join Table 2
ON
Table 1.Column 1=Table 2.Column 1
Right outer join returns all records/rows from right table and from left table
returns only matched records.
Full Outer Joins
Full outer join combines left outer join and right outer join. This join returns
all records/rows from both the tables.
Syntax:
Select * from Table 1
Full Outer Join Table 2
ON
Table 1.Column 1=Table 2.Column 1
Scenario
EmpID EmpName DepID
1 Siddhesh 3
2 Sumit 4
3 Rakesh 1
4 Omkar 2
5 Shailesh 4
DepID EmpName
1 Accounts
2 Sales
3 HR
4 Technical
Tab_Employee Tab_Department
Left Outer Join ( Example )
Query :
SELECT a.DepID , a.DepName , b.EmpID , b.EmpName
FROM Tab_Department a
LEFT OUTER JOIN Tab_Employee b
ON a.DepID = b.DepID;
Result :
DepID DepName EmpID DepName
1 Accounts 3 Rakesh
2 Sales 4 Omkar
3 HR 1 Siddhesh
4 Technical 2 Sumit
4 Technical 5 Shailesh
Right Outer Join ( Example )
Query :
SELECT a.DepID , a.DepName , b.EmpID , b.EmpName
FROM Tab_Department a
RIGHT OUTER JOIN Tab_Employee b
ON a.DepID = b.DepID;
Result :
DepID DepName EmpID DepName
3 HR 1 Siddhesh
4 Technical 2 Sumit
1 Accounts 3 Rakesh
2 Sales 4 Omkar
4 Technical 5 Shailesh
Full Outer Join ( Example )
Query :
SELECT a.EmpID , a.EmpName , b.DepName
FROM Tab_Employee a
FULL OUTER JOIN Tab_Department b
ON a.DepID = b.DepID;
Result :
EmpID EmpName DepName
1 Siddhesh HR
2 Sumit Technical
3 Rakesh Accounts
4 Omkar Sales
5 Shailesh Technical
Cross Joins
This join returns records/rows that are multiplication of record number from
both the tables means each row on left table will related to each row of right
table.
Syntax:
Select * from Table 1
Cross Join Table 2
Scenario
EmpID EmpName
1 Siddhesh
2 Sumit
DepID DepName
1 Accounts
2 Sales
3 HR
4 Technical
Tab_Employee Tab_Department
Cross Join ( Example )
Query :
SELECT a.EmpID , a.EmpName , Tab_Department.DepName
FROM Tab_Employee a
CROSS JOIN Tab_Department ;
Result : EmpID EmpName DepName
1 Siddhesh Accounts
2 Sumit Accounts
1 Siddhesh Sales
2 Sumit Sales
1 Siddhesh HR
2 Sumit HR
1 Siddhesh Technical
2 Sumit Technical
Sql joins

More Related Content

PPT
Sql joins
PPTX
SQL Joins.pptx
PPTX
Sql joins
PPTX
Sql joins inner join self join outer joins
PPT
OODM-object oriented data model
PDF
Primary Key & Foreign Key part10
PDF
SQL JOINS
PPTX
Sql Constraints
Sql joins
SQL Joins.pptx
Sql joins
Sql joins inner join self join outer joins
OODM-object oriented data model
Primary Key & Foreign Key part10
SQL JOINS
Sql Constraints

What's hot (20)

PDF
MySQL INDEXES
PPTX
trigger dbms
PDF
Basic introduction to ms access
PPTX
PPTX
MS Sql Server: Introduction To Database Concepts
ODP
An Introduction to REDIS NoSQL database
PPT
Joins in SQL
PPTX
Basic SQL and History
ODP
Ms sql-server
PPTX
SQL, Embedded SQL, Dynamic SQL and SQLJ
PPT
Aggregate functions
PPT
PL/SQL Introduction and Concepts
PPT
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
PPT
Introduction to sql
PPT
Types Of Join In Sql Server - Join With Example In Sql Server
PPTX
Group By, Order By, and Aliases in SQL
PPTX
Getting Started with MySQL I
PPTX
MYSQL join
MySQL INDEXES
trigger dbms
Basic introduction to ms access
MS Sql Server: Introduction To Database Concepts
An Introduction to REDIS NoSQL database
Joins in SQL
Basic SQL and History
Ms sql-server
SQL, Embedded SQL, Dynamic SQL and SQLJ
Aggregate functions
PL/SQL Introduction and Concepts
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
Introduction to sql
Types Of Join In Sql Server - Join With Example In Sql Server
Group By, Order By, and Aliases in SQL
Getting Started with MySQL I
MYSQL join
Ad

Similar to Sql joins (20)

PDF
SQL JOINS
PPTX
PPTX
Practical Joins Algorithms in database system
PDF
Advance database system(part 8)
PPTX
PPT
joins IN DATA BASE MANAGEMENT SYSTEMSppt
PPT
PPTX
types of SQL Joins
PPTX
Querying_with_T-SQL_-_03 (1).pptx
PPTX
Querying_with_T-SQL_-_03.pptx
PPTX
Lab4 join - all types listed
PPTX
Joins.pptxjjbmmmnnnnnjjjxrhjfluflurulrdudlu
PDF
Joins in databases
PPTX
Presentation of Joins In Database
PPTX
SQL_JOIN ALL TYPE OF JOINS OF MYSQL.PPTX
PPTX
SQL JOIN
PPT
Sql join
PPT
Join sql
PPTX
sql joinsubdjbrjdbjrjnfkjcnkrnfknrkfkrfkrfkrk
SQL JOINS
Practical Joins Algorithms in database system
Advance database system(part 8)
joins IN DATA BASE MANAGEMENT SYSTEMSppt
types of SQL Joins
Querying_with_T-SQL_-_03 (1).pptx
Querying_with_T-SQL_-_03.pptx
Lab4 join - all types listed
Joins.pptxjjbmmmnnnnnjjjxrhjfluflurulrdudlu
Joins in databases
Presentation of Joins In Database
SQL_JOIN ALL TYPE OF JOINS OF MYSQL.PPTX
SQL JOIN
Sql join
Join sql
sql joinsubdjbrjdbjrjnfkjcnkrnfknrkfkrfkrfkrk
Ad

More from Siddhesh Palkar (12)

PPTX
Decision Support System ( DSS )
PPTX
Google Home Assistant
PPTX
3D Printing
PPTX
Management Information System ( MIS )
PPTX
Asp.net file types
PPTX
Inheritance
PPTX
Network security
PPTX
Vb script in asp
PPTX
Building blocks of android
PPTX
Order of boot process in Linux
PPTX
Pin diagram 8085
PPTX
Software Quality Assurance
Decision Support System ( DSS )
Google Home Assistant
3D Printing
Management Information System ( MIS )
Asp.net file types
Inheritance
Network security
Vb script in asp
Building blocks of android
Order of boot process in Linux
Pin diagram 8085
Software Quality Assurance

Recently uploaded (20)

PDF
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
PPTX
Lesson notes of climatology university.
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PPTX
Unit 4 Skeletal System.ppt.pptxopresentatiom
PDF
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
PPTX
History, Philosophy and sociology of education (1).pptx
PPTX
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
PDF
Complications of Minimal Access Surgery at WLH
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
PPTX
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
PDF
Weekly quiz Compilation Jan -July 25.pdf
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
Lesson notes of climatology university.
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
A systematic review of self-coping strategies used by university students to ...
UNIT III MENTAL HEALTH NURSING ASSESSMENT
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Paper A Mock Exam 9_ Attempt review.pdf.
Unit 4 Skeletal System.ppt.pptxopresentatiom
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
History, Philosophy and sociology of education (1).pptx
Onco Emergencies - Spinal cord compression Superior vena cava syndrome Febr...
Complications of Minimal Access Surgery at WLH
Final Presentation General Medicine 03-08-2024.pptx
Chinmaya Tiranga quiz Grand Finale.pdf
medical_surgical_nursing_10th_edition_ignatavicius_TEST_BANK_pdf.pdf
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
Weekly quiz Compilation Jan -July 25.pdf
Practical Manual AGRO-233 Principles and Practices of Natural Farming
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape

Sql joins

  • 2. WHAT IS JOINNING ??? Introduction
  • 3.  A SQL join clause combines columns from one or more tables in a relational database. It creates a set that can be saved as a table or used as it is.  A JOIN is a means for combining columns from one or more tables by using values common to each.
  • 4. Type of SQL Joins Inner Join Outer Join Cross Join
  • 5. Inner Joins Inner join returns only those records that match in both the tables. Syntax: Select * from table 1 INNER JOIN table 2 ON Table 1.Column 1=table 2.Column 1
  • 6. Scenario EmpID EmpName DepID 1 Siddhesh 3 2 Sumit 4 3 Rakesh 1 4 Omkar 2 5 Shailesh 4 DepID DepName 1 Accounts 2 Sales 3 HR 4 Technical Tab_Employee Tab_Department
  • 7. Inner Join ( Example ) Query : SELECT a.EmpID , a.EmpName , Tab_Department.DepName FROM Tab_Employee a INNER JOIN Tab_Department b ON a.DepID = b.DepID; Result : EmpID EmpName DepName 1 Siddhesh HR 2 Sumit Technical 3 Rakesh Accounts 4 Omkar Sales 5 Shailesh Technical
  • 8. Outer Joins There are three types of Outer Joins :  Left Outer Joins  Right Outer Joins  Full Outer Joins
  • 9. Left Outer Joins Left outer join returns all records/rows from left table and from right table returns only matched records. Syntax: Select * from Table 1 Left Outer Join Table 2 ON Table 1.Column 1=Table 2.Column 1
  • 10. Right Outer Joins Syntax: Select * from Table 1 Right Outer Join Table 2 ON Table 1.Column 1=Table 2.Column 1 Right outer join returns all records/rows from right table and from left table returns only matched records.
  • 11. Full Outer Joins Full outer join combines left outer join and right outer join. This join returns all records/rows from both the tables. Syntax: Select * from Table 1 Full Outer Join Table 2 ON Table 1.Column 1=Table 2.Column 1
  • 12. Scenario EmpID EmpName DepID 1 Siddhesh 3 2 Sumit 4 3 Rakesh 1 4 Omkar 2 5 Shailesh 4 DepID EmpName 1 Accounts 2 Sales 3 HR 4 Technical Tab_Employee Tab_Department
  • 13. Left Outer Join ( Example ) Query : SELECT a.DepID , a.DepName , b.EmpID , b.EmpName FROM Tab_Department a LEFT OUTER JOIN Tab_Employee b ON a.DepID = b.DepID; Result : DepID DepName EmpID DepName 1 Accounts 3 Rakesh 2 Sales 4 Omkar 3 HR 1 Siddhesh 4 Technical 2 Sumit 4 Technical 5 Shailesh
  • 14. Right Outer Join ( Example ) Query : SELECT a.DepID , a.DepName , b.EmpID , b.EmpName FROM Tab_Department a RIGHT OUTER JOIN Tab_Employee b ON a.DepID = b.DepID; Result : DepID DepName EmpID DepName 3 HR 1 Siddhesh 4 Technical 2 Sumit 1 Accounts 3 Rakesh 2 Sales 4 Omkar 4 Technical 5 Shailesh
  • 15. Full Outer Join ( Example ) Query : SELECT a.EmpID , a.EmpName , b.DepName FROM Tab_Employee a FULL OUTER JOIN Tab_Department b ON a.DepID = b.DepID; Result : EmpID EmpName DepName 1 Siddhesh HR 2 Sumit Technical 3 Rakesh Accounts 4 Omkar Sales 5 Shailesh Technical
  • 16. Cross Joins This join returns records/rows that are multiplication of record number from both the tables means each row on left table will related to each row of right table. Syntax: Select * from Table 1 Cross Join Table 2
  • 17. Scenario EmpID EmpName 1 Siddhesh 2 Sumit DepID DepName 1 Accounts 2 Sales 3 HR 4 Technical Tab_Employee Tab_Department
  • 18. Cross Join ( Example ) Query : SELECT a.EmpID , a.EmpName , Tab_Department.DepName FROM Tab_Employee a CROSS JOIN Tab_Department ; Result : EmpID EmpName DepName 1 Siddhesh Accounts 2 Sumit Accounts 1 Siddhesh Sales 2 Sumit Sales 1 Siddhesh HR 2 Sumit HR 1 Siddhesh Technical 2 Sumit Technical