SlideShare a Scribd company logo
1 of 24
PRESENTATION ON JOINS
By:- BIHARA SINGH
What Are Joins ??
#JOINS
•Joins help retrieving data from two or
more database tables.
•The tables are mutually related using
primary and foreign keys.
WHY TO USE JOINS ????
• We can run queries one by one, use output of each in
successive queries. Of course, that is possible. But using
JOINs, you can get the work done by using only a one
query with any search parameters.
• On the other hand MySQL can achieve better
performance with JOINs as it can use Indexing.
• Simply use of single JOIN query instead running multiple
queries do reduce server overhead.
WHAT JOIN DO ??
• Joins help retrieving data from two or more database tables.
• The tables are mutually related using primary and foreign keys.
• It can join the table vertically as well as horizontally.
Table A
Table B
Table A Table B
TABLES WE WILL USE …
TABLE 1
TABLE 2
TYPES OF JOINS
• CROSS JOIN OR CARTESSIAN PRODUCT
• INNER JOIN
• OUTER JOINS
• LEFT JOIN
• RIGHT JOIN
CROSS JOIN
• Cross JOIN is a simplest form of JOINs which matches
each row from one database table to all rows of
another
• In other words it gives us combinations of each row of
first table with all records in second table.
• Syntax: SELECT * FROM ‘movies’ CROSS JOIN ‘members’
INNER JOIN
• The inner JOIN is used to return rows from both tables
that satisfy the given condition.
• Syntax: SELECT members.’first_name’ , members.`last_name`
, movies.`title` FROM members ,movies WHERE movies.`id` =
members.`movie_id`
OUTER JOIN
• MySQL Outer JOINs return all records matching from
both tables .
• It can detect records having no match in joined table.
It returns NULL values for records of joined table if no
match is found.
• Sounds Confusing ? Let's look into an example -
LEFT JOIN
• Assume now you want to get titles of all movies together with
names of members who have rented them. It is clear that some
movies have not being rented by any one. We can simply
use LEFT JOIN for the purpose.
SYNTAX
• The LEFT JOIN returns all the rows from the table on the left
even if no matching rows have been found in the table on the
right. Where no matches have been found in the table on the
right, NULL is returned.
•
RIGHT JOIN
• RIGHT JOIN is obviously the opposite of LEFT JOIN. The RIGHT
JOIN returns all the columns from the table on the right even if
no matching rows have been found in the table on the left.
Where no matches have been found in the table on the left,
NULL is returned.
SYNTAX
SUMMARY
• JOINS allow us to combine data from more than one
table into a single result set.
• JOINS have better performance compared to sub
queries
• INNER JOINS only return rows that meet the given
criteria.
• OUTER JOINS can also return rows where no matches
have been found. The unmatched rows are returned
with the NULL keyword.
Continue…
• The major JOIN types include Inner, Left Outer, Right
Outer, Cross JOINS etc.
• The frequently used clause in JOIN operations is "ON".
"USING" clause requires that matching columns be of
the same name.
• JOINS can also be used in other clauses such as GROUP
BY, WHERE, SUB QUERIES, AGGREGATE FUNCTIONS etc.
R
E
F
E
R
E
N
C
E
S
WWW.W3RESOURCES.COM
WWW.WIKIPEDIA.COM
WWW.TUTORIALSPOINT.COM
THANKS FOR LISTENING ME …

More Related Content

What's hot

SQL Queries
SQL QueriesSQL Queries
SQL QueriesNilt1234
 
MS Sql Server: Joining Databases
MS Sql Server: Joining DatabasesMS Sql Server: Joining Databases
MS Sql Server: Joining DatabasesDataminingTools Inc
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL CommandsShrija Madhu
 
SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functionsVikas Gupta
 
Group By, Having Clause and Order By clause
Group By, Having Clause and Order By clause Group By, Having Clause and Order By clause
Group By, Having Clause and Order By clause Deepam Aggarwal
 
SQL Joins With Examples | Edureka
SQL Joins With Examples | EdurekaSQL Joins With Examples | Edureka
SQL Joins With Examples | EdurekaEdureka!
 
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 Serverprogrammings guru
 
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 SQLMSB Academy
 

What's hot (20)

Sql subquery
Sql  subquerySql  subquery
Sql subquery
 
Oracle: Joins
Oracle: JoinsOracle: Joins
Oracle: Joins
 
SQL commands
SQL commandsSQL commands
SQL commands
 
SQL Commands
SQL Commands SQL Commands
SQL Commands
 
Sql joins
Sql joinsSql joins
Sql joins
 
SQL Queries
SQL QueriesSQL Queries
SQL Queries
 
MS Sql Server: Joining Databases
MS Sql Server: Joining DatabasesMS Sql Server: Joining Databases
MS Sql Server: Joining Databases
 
SQL - DML and DDL Commands
SQL - DML and DDL CommandsSQL - DML and DDL Commands
SQL - DML and DDL Commands
 
SQL select statement and functions
SQL select statement and functionsSQL select statement and functions
SQL select statement and functions
 
Group By, Having Clause and Order By clause
Group By, Having Clause and Order By clause Group By, Having Clause and Order By clause
Group By, Having Clause and Order By clause
 
Advanced sql
Advanced sqlAdvanced sql
Advanced sql
 
8. sql
8. sql8. sql
8. sql
 
SQL Joins With Examples | Edureka
SQL Joins With Examples | EdurekaSQL Joins With Examples | Edureka
SQL Joins With Examples | Edureka
 
Mysql
MysqlMysql
Mysql
 
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
 
joins in database
 joins in database joins in database
joins in database
 
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
 
PLSQL
PLSQLPLSQL
PLSQL
 
SQL Functions
SQL FunctionsSQL Functions
SQL Functions
 
SQL Views
SQL ViewsSQL Views
SQL Views
 

Similar to Joins

Tech Jam 01 - Database Querying
Tech Jam 01 - Database QueryingTech Jam 01 - Database Querying
Tech Jam 01 - Database QueryingRodger Oates
 
Advance database system(part 8)
Advance database system(part 8)Advance database system(part 8)
Advance database system(part 8)Abdullah Khosa
 
Aggregate functions in SQL.pptx
Aggregate functions in SQL.pptxAggregate functions in SQL.pptx
Aggregate functions in SQL.pptxSherinRappai
 
Aggregate functions in SQL.pptx
Aggregate functions in SQL.pptxAggregate functions in SQL.pptx
Aggregate functions in SQL.pptxSherinRappai1
 
joins in dbms its describes about how joins are important and necessity in d...
joins in dbms  its describes about how joins are important and necessity in d...joins in dbms  its describes about how joins are important and necessity in d...
joins in dbms its describes about how joins are important and necessity in d...AshokRachapalli1
 
Binary search tree operations
Binary search tree operationsBinary search tree operations
Binary search tree operationsKamran Zafar
 
How oracle query works (The SQL Optimizers)
How oracle query works (The SQL Optimizers)How oracle query works (The SQL Optimizers)
How oracle query works (The SQL Optimizers)Hosein Zare
 
Introduction of sql server indexing
Introduction of sql server indexingIntroduction of sql server indexing
Introduction of sql server indexingMahabubur Rahaman
 
MergeResult_2024_02_09_08_59_11.pptx
MergeResult_2024_02_09_08_59_11.pptxMergeResult_2024_02_09_08_59_11.pptx
MergeResult_2024_02_09_08_59_11.pptxKrishnansuSenapati
 
SQL dabatase interveiw pdf for interveiw preparation
SQL dabatase  interveiw pdf for interveiw preparationSQL dabatase  interveiw pdf for interveiw preparation
SQL dabatase interveiw pdf for interveiw preparationkumarvikesh2841998
 

Similar to Joins (20)

SQL Join's
SQL Join'sSQL Join's
SQL Join's
 
SQL JOINS
SQL JOINSSQL JOINS
SQL JOINS
 
Tech Jam 01 - Database Querying
Tech Jam 01 - Database QueryingTech Jam 01 - Database Querying
Tech Jam 01 - Database Querying
 
Advance database system(part 8)
Advance database system(part 8)Advance database system(part 8)
Advance database system(part 8)
 
Aggregate functions in SQL.pptx
Aggregate functions in SQL.pptxAggregate functions in SQL.pptx
Aggregate functions in SQL.pptx
 
Aggregate functions in SQL.pptx
Aggregate functions in SQL.pptxAggregate functions in SQL.pptx
Aggregate functions in SQL.pptx
 
Sql
SqlSql
Sql
 
Joins in m ysql
Joins in m ysqlJoins in m ysql
Joins in m ysql
 
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
Views, Triggers, Functions, Stored Procedures,  Indexing and JoinsViews, Triggers, Functions, Stored Procedures,  Indexing and Joins
Views, Triggers, Functions, Stored Procedures, Indexing and Joins
 
joins in dbms its describes about how joins are important and necessity in d...
joins in dbms  its describes about how joins are important and necessity in d...joins in dbms  its describes about how joins are important and necessity in d...
joins in dbms its describes about how joins are important and necessity in d...
 
Sql Tutorials
Sql TutorialsSql Tutorials
Sql Tutorials
 
Join query
Join queryJoin query
Join query
 
MYSQL join
MYSQL joinMYSQL join
MYSQL join
 
Binary search tree operations
Binary search tree operationsBinary search tree operations
Binary search tree operations
 
How oracle query works (The SQL Optimizers)
How oracle query works (The SQL Optimizers)How oracle query works (The SQL Optimizers)
How oracle query works (The SQL Optimizers)
 
MySQL JOIN & UNION
MySQL JOIN & UNIONMySQL JOIN & UNION
MySQL JOIN & UNION
 
Introduction of sql server indexing
Introduction of sql server indexingIntroduction of sql server indexing
Introduction of sql server indexing
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
MergeResult_2024_02_09_08_59_11.pptx
MergeResult_2024_02_09_08_59_11.pptxMergeResult_2024_02_09_08_59_11.pptx
MergeResult_2024_02_09_08_59_11.pptx
 
SQL dabatase interveiw pdf for interveiw preparation
SQL dabatase  interveiw pdf for interveiw preparationSQL dabatase  interveiw pdf for interveiw preparation
SQL dabatase interveiw pdf for interveiw preparation
 

Recently uploaded

Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort servicejennyeacort
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxPoojaBan
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
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
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
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
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 

Recently uploaded (20)

Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort serviceGurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
Gurgaon ✡️9711147426✨Call In girls Gurgaon Sector 51 escort service
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
Heart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptxHeart Disease Prediction using machine learning.pptx
Heart Disease Prediction using machine learning.pptx
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
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 )
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
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...
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 

Joins

  • 3. #JOINS •Joins help retrieving data from two or more database tables. •The tables are mutually related using primary and foreign keys.
  • 4. WHY TO USE JOINS ???? • We can run queries one by one, use output of each in successive queries. Of course, that is possible. But using JOINs, you can get the work done by using only a one query with any search parameters. • On the other hand MySQL can achieve better performance with JOINs as it can use Indexing. • Simply use of single JOIN query instead running multiple queries do reduce server overhead.
  • 5. WHAT JOIN DO ?? • Joins help retrieving data from two or more database tables. • The tables are mutually related using primary and foreign keys. • It can join the table vertically as well as horizontally. Table A Table B Table A Table B
  • 6. TABLES WE WILL USE …
  • 9. TYPES OF JOINS • CROSS JOIN OR CARTESSIAN PRODUCT • INNER JOIN • OUTER JOINS • LEFT JOIN • RIGHT JOIN
  • 10. CROSS JOIN • Cross JOIN is a simplest form of JOINs which matches each row from one database table to all rows of another • In other words it gives us combinations of each row of first table with all records in second table. • Syntax: SELECT * FROM ‘movies’ CROSS JOIN ‘members’
  • 11.
  • 12. INNER JOIN • The inner JOIN is used to return rows from both tables that satisfy the given condition. • Syntax: SELECT members.’first_name’ , members.`last_name` , movies.`title` FROM members ,movies WHERE movies.`id` = members.`movie_id`
  • 13.
  • 14. OUTER JOIN • MySQL Outer JOINs return all records matching from both tables . • It can detect records having no match in joined table. It returns NULL values for records of joined table if no match is found. • Sounds Confusing ? Let's look into an example -
  • 15. LEFT JOIN • Assume now you want to get titles of all movies together with names of members who have rented them. It is clear that some movies have not being rented by any one. We can simply use LEFT JOIN for the purpose.
  • 16. SYNTAX • The LEFT JOIN returns all the rows from the table on the left even if no matching rows have been found in the table on the right. Where no matches have been found in the table on the right, NULL is returned. •
  • 17.
  • 18. RIGHT JOIN • RIGHT JOIN is obviously the opposite of LEFT JOIN. The RIGHT JOIN returns all the columns from the table on the right even if no matching rows have been found in the table on the left. Where no matches have been found in the table on the left, NULL is returned.
  • 20.
  • 21. SUMMARY • JOINS allow us to combine data from more than one table into a single result set. • JOINS have better performance compared to sub queries • INNER JOINS only return rows that meet the given criteria. • OUTER JOINS can also return rows where no matches have been found. The unmatched rows are returned with the NULL keyword.
  • 22. Continue… • The major JOIN types include Inner, Left Outer, Right Outer, Cross JOINS etc. • The frequently used clause in JOIN operations is "ON". "USING" clause requires that matching columns be of the same name. • JOINS can also be used in other clauses such as GROUP BY, WHERE, SUB QUERIES, AGGREGATE FUNCTIONS etc.