SlideShare a Scribd company logo
1 of 11
http://www.programmingsguru.com/article/types-of-joins-in-sql-15
Introduction
• A JOIN is a means for merging fields from two tables by using values
common to each. SQL Joins condition is a part of the sql query that
fetch/retrieve rows(data) from two or more tables. The records from the
tables are fetched based on some values that are common to each."How
many types of joins in sql" this question ask so many times in interviews,
We have two tables
tbl_employee
tbl_department
The Different Types of Joins in SQL Server
1 - INNER JOIN : A Inner Join is a type of sql join which returns all
the rows from both tables where there is a match. Means return
matching records for both tables.
2 - SELF JOIN : A Self Join is a type of sql join which is used to
join a table to itself. In this join both the columns belong to the
same table.
SELECT Emp1.Empid, Emp1.EmpName,Emp2.Departmentid FROM
tbl_employee Emp1 INNER JOIN tbl_employee Emp2 ON
Emp1.Empid=Emp2.Empid
3 - OUTER JOIN : In this join includes rows even if they don't have
related rows in the joined table. There are three different Outer
Join methods..
Right outer Join : In This join returns all the rows from the right table
in conjunction with the matching rows from the left table.
Left outer Join : In This join returns all the rows from the left table in
conjunction with the matching rows from the right table.
Full Outer Join : This join combines left outer join and right outer join. It returns
row from both tables wether it's match or not.
4 - CROSS JOIN : This join combines all the rows from the left
table with every row from the right table. This type of join is
required when we want to select all the possible combinations
of rows and columns from both the tables.
http://www.programmingsguru.com
https://plus.google.com/u/0/106132290230951995384/posts
https://www.facebook.com/programmings4you
https://twitter.com/programingsguru

More Related Content

What's hot (20)

Constraints In Sql
Constraints In SqlConstraints In Sql
Constraints In Sql
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
Database Triggers
Database TriggersDatabase Triggers
Database Triggers
 
Sql joins
Sql joinsSql joins
Sql joins
 
SQL Joins With Examples | Edureka
SQL Joins With Examples | EdurekaSQL Joins With Examples | Edureka
SQL Joins With Examples | Edureka
 
Sql joins inner join self join outer joins
Sql joins inner join self join outer joinsSql joins inner join self join outer joins
Sql joins inner join self join outer joins
 
DML Commands
DML CommandsDML Commands
DML Commands
 
Triggers
TriggersTriggers
Triggers
 
Sql commands
Sql commandsSql commands
Sql commands
 
Sql subquery
Sql  subquerySql  subquery
Sql subquery
 
Group By, Order By, and Aliases in SQL
Group By, Order By, and Aliases in SQLGroup By, Order By, and Aliases in SQL
Group By, Order By, and Aliases in SQL
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
SQL Queries
SQL QueriesSQL Queries
SQL Queries
 
SQL Joins.pptx
SQL Joins.pptxSQL Joins.pptx
SQL Joins.pptx
 
Database Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and deleteDatabase Management - Lecture 2 - SQL select, insert, update and delete
Database Management - Lecture 2 - SQL select, insert, update and delete
 
Sql join
Sql  joinSql  join
Sql join
 
Basic sql Commands
Basic sql CommandsBasic sql Commands
Basic sql Commands
 
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with ExamplesDML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
DML, DDL, DCL ,DRL/DQL and TCL Statements in SQL with Examples
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
Triggers in SQL | Edureka
Triggers in SQL | EdurekaTriggers in SQL | Edureka
Triggers in SQL | Edureka
 

Viewers also liked

SQL Joins and Query Optimization
SQL Joins and Query OptimizationSQL Joins and Query Optimization
SQL Joins and Query OptimizationBrian Gallagher
 
MS Sql Server: Joining Databases
MS Sql Server: Joining DatabasesMS Sql Server: Joining Databases
MS Sql Server: Joining DatabasesDataminingTools Inc
 
Database Introduction - Join Query
Database Introduction - Join QueryDatabase Introduction - Join Query
Database Introduction - Join QueryDudy Ali
 
Everything about Database JOINS and Relationships
Everything about Database JOINS and RelationshipsEverything about Database JOINS and Relationships
Everything about Database JOINS and RelationshipsAbdul Rahman Sherzad
 
Joins – which, when and why
Joins – which, when and whyJoins – which, when and why
Joins – which, when and whyMichal Simonik
 
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NFDatabase Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NFOum Saokosal
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Beat Signer
 
SQL Joinning.Database
SQL Joinning.DatabaseSQL Joinning.Database
SQL Joinning.DatabaseUmme habiba
 
Sql server JOIN
Sql server JOINSql server JOIN
Sql server JOINRiteshkiit
 
Inner join and outer join
Inner join and outer joinInner join and outer join
Inner join and outer joinNargis Ehsan
 

Viewers also liked (20)

SQL Joins and Query Optimization
SQL Joins and Query OptimizationSQL Joins and Query Optimization
SQL Joins and Query Optimization
 
Sql joins
Sql joinsSql joins
Sql joins
 
SQL Joins
SQL JoinsSQL Joins
SQL Joins
 
Semi join
Semi joinSemi join
Semi join
 
MS Sql Server: Joining Databases
MS Sql Server: Joining DatabasesMS Sql Server: Joining Databases
MS Sql Server: Joining Databases
 
SQL JOINS- Reena P V
SQL JOINS- Reena P VSQL JOINS- Reena P V
SQL JOINS- Reena P V
 
SQL JOIN Explained Visually
SQL JOIN Explained VisuallySQL JOIN Explained Visually
SQL JOIN Explained Visually
 
Join
JoinJoin
Join
 
Database Introduction - Join Query
Database Introduction - Join QueryDatabase Introduction - Join Query
Database Introduction - Join Query
 
SQL
SQLSQL
SQL
 
Everything about Database JOINS and Relationships
Everything about Database JOINS and RelationshipsEverything about Database JOINS and Relationships
Everything about Database JOINS and Relationships
 
Joins – which, when and why
Joins – which, when and whyJoins – which, when and why
Joins – which, when and why
 
SQL : introduction
SQL : introductionSQL : introduction
SQL : introduction
 
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NFDatabase Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
Database Normalization 1NF, 2NF, 3NF, BCNF, 4NF, 5NF
 
Sql ppt
Sql pptSql ppt
Sql ppt
 
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
Structured Query Language (SQL) - Lecture 5 - Introduction to Databases (1007...
 
SQL Joinning.Database
SQL Joinning.DatabaseSQL Joinning.Database
SQL Joinning.Database
 
Sql server JOIN
Sql server JOINSql server JOIN
Sql server JOIN
 
Inner join and outer join
Inner join and outer joinInner join and outer join
Inner join and outer join
 
types of SQL Joins
 types of SQL Joins types of SQL Joins
types of SQL Joins
 

Similar to Types Of Join In Sql Server - Join With Example In Sql Server

Similar to Types Of Join In Sql Server - Join With Example In Sql Server (20)

Joins and unions
Joins and unionsJoins and unions
Joins and unions
 
Joins and unions
Joins and unionsJoins and unions
Joins and unions
 
Join query
Join queryJoin query
Join query
 
SQL Join's
SQL Join'sSQL Join's
SQL Join's
 
SQL JOINS
SQL JOINSSQL JOINS
SQL JOINS
 
Sql(structured query language)
Sql(structured query language)Sql(structured query language)
Sql(structured query language)
 
3)12th_L8_Join-Set-Operations.pdf
3)12th_L8_Join-Set-Operations.pdf3)12th_L8_Join-Set-Operations.pdf
3)12th_L8_Join-Set-Operations.pdf
 
JOINS.pptx
JOINS.pptxJOINS.pptx
JOINS.pptx
 
Joins SQL Server
Joins SQL ServerJoins SQL Server
Joins SQL Server
 
MYSQL join
MYSQL joinMYSQL join
MYSQL join
 
Relational algebra
Relational algebraRelational algebra
Relational algebra
 
Advance database system(part 8)
Advance database system(part 8)Advance database system(part 8)
Advance database system(part 8)
 
Assignment 4
Assignment 4Assignment 4
Assignment 4
 
SQL Joins and View.pptx
SQL Joins and View.pptxSQL Joins and View.pptx
SQL Joins and View.pptx
 
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.ppt
Joins.pptJoins.ppt
Joins.ppt
 
Day-2 SQL Theory_V1.pptx
Day-2 SQL Theory_V1.pptxDay-2 SQL Theory_V1.pptx
Day-2 SQL Theory_V1.pptx
 
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
 
Join sql
Join sqlJoin sql
Join sql
 
V19 join method-c
V19 join method-cV19 join method-c
V19 join method-c
 

Recently uploaded

Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxAshokKarra1
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSJoshuaGantuangco2
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfPatidar M
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxAnupkumar Sharma
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxVanesaIglesias10
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4MiaBumagat1
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management systemChristalin Nelson
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Celine George
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationRosabel UA
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parentsnavabharathschool99
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Seán Kennedy
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17Celine George
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 

Recently uploaded (20)

YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptxYOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
YOUVE_GOT_EMAIL_PRELIMS_EL_DORADO_2024.pptx
 
Karra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptxKarra SKD Conference Presentation Revised.pptx
Karra SKD Conference Presentation Revised.pptx
 
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTSGRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
GRADE 4 - SUMMATIVE TEST QUARTER 4 ALL SUBJECTS
 
Active Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdfActive Learning Strategies (in short ALS).pdf
Active Learning Strategies (in short ALS).pdf
 
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptxMULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
MULTIDISCIPLINRY NATURE OF THE ENVIRONMENTAL STUDIES.pptx
 
ROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptxROLES IN A STAGE PRODUCTION in arts.pptx
ROLES IN A STAGE PRODUCTION in arts.pptx
 
ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4ANG SEKTOR NG agrikultura.pptx QUARTER 4
ANG SEKTOR NG agrikultura.pptx QUARTER 4
 
Concurrency Control in Database Management system
Concurrency Control in Database Management systemConcurrency Control in Database Management system
Concurrency Control in Database Management system
 
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
Incoming and Outgoing Shipments in 3 STEPS Using Odoo 17
 
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptxLEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
LEFT_ON_C'N_ PRELIMS_EL_DORADO_2024.pptx
 
Activity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translationActivity 2-unit 2-update 2024. English translation
Activity 2-unit 2-update 2024. English translation
 
Choosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for ParentsChoosing the Right CBSE School A Comprehensive Guide for Parents
Choosing the Right CBSE School A Comprehensive Guide for Parents
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...Student Profile Sample - We help schools to connect the data they have, with ...
Student Profile Sample - We help schools to connect the data they have, with ...
 
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptxYOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
YOUVE GOT EMAIL_FINALS_EL_DORADO_2024.pptx
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17How to Add Barcode on PDF Report in Odoo 17
How to Add Barcode on PDF Report in Odoo 17
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 

Types Of Join In Sql Server - Join With Example In Sql Server

  • 2. Introduction • A JOIN is a means for merging fields from two tables by using values common to each. SQL Joins condition is a part of the sql query that fetch/retrieve rows(data) from two or more tables. The records from the tables are fetched based on some values that are common to each."How many types of joins in sql" this question ask so many times in interviews,
  • 3. We have two tables tbl_employee tbl_department
  • 4. The Different Types of Joins in SQL Server 1 - INNER JOIN : A Inner Join is a type of sql join which returns all the rows from both tables where there is a match. Means return matching records for both tables.
  • 5. 2 - SELF JOIN : A Self Join is a type of sql join which is used to join a table to itself. In this join both the columns belong to the same table. SELECT Emp1.Empid, Emp1.EmpName,Emp2.Departmentid FROM tbl_employee Emp1 INNER JOIN tbl_employee Emp2 ON Emp1.Empid=Emp2.Empid
  • 6. 3 - OUTER JOIN : In this join includes rows even if they don't have related rows in the joined table. There are three different Outer Join methods.. Right outer Join : In This join returns all the rows from the right table in conjunction with the matching rows from the left table.
  • 7. Left outer Join : In This join returns all the rows from the left table in conjunction with the matching rows from the right table.
  • 8. Full Outer Join : This join combines left outer join and right outer join. It returns row from both tables wether it's match or not.
  • 9. 4 - CROSS JOIN : This join combines all the rows from the left table with every row from the right table. This type of join is required when we want to select all the possible combinations of rows and columns from both the tables.