SlideShare a Scribd company logo
Joining
Tables
U N I T3 : M Y S Q L B A S I C S
U N I T3 : M Y S Q L B A S I C S
Joining Tables
A table is an arrangement of information or
data, typically in rows and columns, or
possibly in a more complex structure.
Database is a collection of Tables
Intro To Table
U N I T3 : M Y S Q L B A S I C S
Joining Tables
A J
OIN clause is used to combine rows
from two or more tables, based on a
related column between them.
U N I T3 : M Y S Q L B A S I C S
Joins are used to stitch the database back together
to make it easy to read and use.
They match rows between tables.
In most cases we're matching a column value from
one table with another.
Uses:
Joining Tables
U N I T3 : M Y S Q L B A S I C S
Types:
Natural JOIN J
OIN...ON
Joining Tables
Using As
U N I T3 : M Y S Q L B A S I C S
Joining Tables
Natural JOIN
This kind of join takes two tables and automatically joins
columns that have the same name
Syntax
SE L E C T *
F RO M T A B L E 1
N A T U RA L JO IN T A B L E 2;
U N I T3 : M Y S Q L B A S I C S
Joining Tables
Natural JOIN Example
SELECT *FROM company
NATURAL JOIN foods;
U N I T3 : M Y S Q L B A S I C S
Joining Tables
If you wish to specify the column on which to join two
tables, use the JOIN...ON construct.
Syntax
SE L E C T *
F RO M T a b l e 1 JO IN T a b l e 2 O N
T a b l e 1. i d =T a b l e 2. i d ;
JOIN...ON
Improve query readability by creating aliases using the AS
keyword
Aliases can be particularly useful when you have long
queries that reference the same table names many times.
Syntax
SELECT *from Table1 AS T1, Table2 AS T2
WHERE T1.id=T2.id;
U N I T3 : M Y S Q L B A S I C S
Joining Tables
Using AS
U N I T3 : M Y S Q L B A S I C S
Joining Tables
SELECT name,author,title FROM
customers JOIN classics ON
customers.isbn=classics.isbn;
JOIN ON Using AS
SELECT name,author,title FROM
customers AS cust, classics AS
class WHERE
cust.isbn=class.isbn;
+ + + +
| name | author | title |
+ + + +
| Joe Bloggs | Charles Dickens | The Old Curiosity Shop |
| Mary Smith | Jane Austen | Pride and Prejudice |
| Jack Wilson | Charles Darwin | The Origin of Species |
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
U N I T 3 : M Y S Q L B A S I C S
Joining Tables
QUERIES?

More Related Content

Similar to Joining Tables.pptx

SQL
SQLSQL
Advanced Database Systems.pptx
Advanced Database Systems.pptxAdvanced Database Systems.pptx
Advanced Database Systems.pptx
EllenGracePorras
 
Les05 (Displaying Data from Multiple Table)
Les05 (Displaying Data from Multiple Table)Les05 (Displaying Data from Multiple Table)
Les05 (Displaying Data from Multiple Table)
Achmad Solichin
 
Day-2 SQL Theory_V1.pptx
Day-2 SQL Theory_V1.pptxDay-2 SQL Theory_V1.pptx
Day-2 SQL Theory_V1.pptx
uzmasulthana3
 
ADV PPT 2 LAB.pptx
ADV PPT 2 LAB.pptxADV PPT 2 LAB.pptx
ADV PPT 2 LAB.pptx
ArjayBalberan1
 
SQL
SQLSQL
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
 
3 inner plumbing Excel tips
3 inner plumbing Excel tips3 inner plumbing Excel tips
3 inner plumbing Excel tips
Martin van Wunnik
 
USING VLOOKUP FUNCTION
USING VLOOKUP FUNCTIONUSING VLOOKUP FUNCTION
USING VLOOKUP FUNCTION
Ruffson Panganiban
 
Les05
Les05Les05
Using vlookup in excel
Using vlookup in excelUsing vlookup in excel
Using vlookup in excel
megankilb
 
1 introduction to my sql
1 introduction to my sql1 introduction to my sql
1 introduction to my sql
Prof. Erwin Globio
 
Introduction to micro soft Training ms Excel.ppt
Introduction to micro soft Training ms Excel.pptIntroduction to micro soft Training ms Excel.ppt
Introduction to micro soft Training ms Excel.ppt
dejene3
 
tabulation and cross tabulation: data processsing
tabulation and cross tabulation: data processsingtabulation and cross tabulation: data processsing
tabulation and cross tabulation: data processsing
ssuserb9efd7
 
Excel notes by satish kumar avunoori
Excel notes by satish kumar avunooriExcel notes by satish kumar avunoori
Excel notes by satish kumar avunoori
Satish Kumar
 
Les04
Les04Les04
DBMS.pdf
DBMS.pdfDBMS.pdf
DBMS.pdf
Rishab Saini
 
Lesson 15
Lesson 15Lesson 15
Lesson 15
Tracie King
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
jainendraKUMAR55
 
Sql2
Sql2Sql2
Sql2
5h4m4n
 

Similar to Joining Tables.pptx (20)

SQL
SQLSQL
SQL
 
Advanced Database Systems.pptx
Advanced Database Systems.pptxAdvanced Database Systems.pptx
Advanced Database Systems.pptx
 
Les05 (Displaying Data from Multiple Table)
Les05 (Displaying Data from Multiple Table)Les05 (Displaying Data from Multiple Table)
Les05 (Displaying Data from Multiple Table)
 
Day-2 SQL Theory_V1.pptx
Day-2 SQL Theory_V1.pptxDay-2 SQL Theory_V1.pptx
Day-2 SQL Theory_V1.pptx
 
ADV PPT 2 LAB.pptx
ADV PPT 2 LAB.pptxADV PPT 2 LAB.pptx
ADV PPT 2 LAB.pptx
 
SQL
SQLSQL
SQL
 
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
 
3 inner plumbing Excel tips
3 inner plumbing Excel tips3 inner plumbing Excel tips
3 inner plumbing Excel tips
 
USING VLOOKUP FUNCTION
USING VLOOKUP FUNCTIONUSING VLOOKUP FUNCTION
USING VLOOKUP FUNCTION
 
Les05
Les05Les05
Les05
 
Using vlookup in excel
Using vlookup in excelUsing vlookup in excel
Using vlookup in excel
 
1 introduction to my sql
1 introduction to my sql1 introduction to my sql
1 introduction to my sql
 
Introduction to micro soft Training ms Excel.ppt
Introduction to micro soft Training ms Excel.pptIntroduction to micro soft Training ms Excel.ppt
Introduction to micro soft Training ms Excel.ppt
 
tabulation and cross tabulation: data processsing
tabulation and cross tabulation: data processsingtabulation and cross tabulation: data processsing
tabulation and cross tabulation: data processsing
 
Excel notes by satish kumar avunoori
Excel notes by satish kumar avunooriExcel notes by satish kumar avunoori
Excel notes by satish kumar avunoori
 
Les04
Les04Les04
Les04
 
DBMS.pdf
DBMS.pdfDBMS.pdf
DBMS.pdf
 
Lesson 15
Lesson 15Lesson 15
Lesson 15
 
DBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptxDBMS and SQL(structured query language) .pptx
DBMS and SQL(structured query language) .pptx
 
Sql2
Sql2Sql2
Sql2
 

Recently uploaded

HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
deepaannamalai16
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
nitinpv4ai
 
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
indexPub
 
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
ImMuslim
 
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
TechSoup
 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
David Douglas School District
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
zuzanka
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Henry Hollis
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
deepaannamalai16
 
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptxA Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
OH TEIK BIN
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
سمير بسيوني
 
How to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in useHow to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in use
Celine George
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
National Information Standards Organization (NISO)
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
giancarloi8888
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
Himanshu Rai
 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
National Information Standards Organization (NISO)
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
Nguyen Thanh Tu Collection
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapitolTechU
 
Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.
IsmaelVazquez38
 
How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17
Celine George
 

Recently uploaded (20)

HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
 
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
THE SACRIFICE HOW PRO-PALESTINE PROTESTS STUDENTS ARE SACRIFICING TO CHANGE T...
 
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
Geography as a Discipline Chapter 1 __ Class 11 Geography NCERT _ Class Notes...
 
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
 
Juneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School DistrictJuneteenth Freedom Day 2024 David Douglas School District
Juneteenth Freedom Day 2024 David Douglas School District
 
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptxRESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
RESULTS OF THE EVALUATION QUESTIONNAIRE.pptx
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
 
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptxA Free 200-Page eBook ~ Brain and Mind Exercise.pptx
A Free 200-Page eBook ~ Brain and Mind Exercise.pptx
 
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdfمصحف القراءات العشر   أعد أحرف الخلاف سمير بسيوني.pdf
مصحف القراءات العشر أعد أحرف الخلاف سمير بسيوني.pdf
 
How to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in useHow to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in use
 
Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"Benner "Expanding Pathways to Publishing Careers"
Benner "Expanding Pathways to Publishing Careers"
 
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdfREASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
REASIGNACION 2024 UGEL CHUPACA 2024 UGEL CHUPACA.pdf
 
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem studentsRHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
RHEOLOGY Physical pharmaceutics-II notes for B.pharm 4th sem students
 
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
Jemison, MacLaughlin, and Majumder "Broadening Pathways for Editors and Authors"
 
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
BÀI TẬP BỔ TRỢ TIẾNG ANH LỚP 8 - CẢ NĂM - FRIENDS PLUS - NĂM HỌC 2023-2024 (B...
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
 
Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.Bossa N’ Roll Records by Ismael Vazquez.
Bossa N’ Roll Records by Ismael Vazquez.
 
How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17How to Manage Reception Report in Odoo 17
How to Manage Reception Report in Odoo 17
 

Joining Tables.pptx

  • 1. Joining Tables U N I T3 : M Y S Q L B A S I C S
  • 2. U N I T3 : M Y S Q L B A S I C S Joining Tables A table is an arrangement of information or data, typically in rows and columns, or possibly in a more complex structure. Database is a collection of Tables Intro To Table
  • 3. U N I T3 : M Y S Q L B A S I C S Joining Tables A J OIN clause is used to combine rows from two or more tables, based on a related column between them.
  • 4. U N I T3 : M Y S Q L B A S I C S Joins are used to stitch the database back together to make it easy to read and use. They match rows between tables. In most cases we're matching a column value from one table with another. Uses: Joining Tables
  • 5. U N I T3 : M Y S Q L B A S I C S Types: Natural JOIN J OIN...ON Joining Tables Using As
  • 6. U N I T3 : M Y S Q L B A S I C S Joining Tables Natural JOIN This kind of join takes two tables and automatically joins columns that have the same name Syntax SE L E C T * F RO M T A B L E 1 N A T U RA L JO IN T A B L E 2;
  • 7. U N I T3 : M Y S Q L B A S I C S Joining Tables Natural JOIN Example SELECT *FROM company NATURAL JOIN foods;
  • 8. U N I T3 : M Y S Q L B A S I C S Joining Tables If you wish to specify the column on which to join two tables, use the JOIN...ON construct. Syntax SE L E C T * F RO M T a b l e 1 JO IN T a b l e 2 O N T a b l e 1. i d =T a b l e 2. i d ; JOIN...ON
  • 9. Improve query readability by creating aliases using the AS keyword Aliases can be particularly useful when you have long queries that reference the same table names many times. Syntax SELECT *from Table1 AS T1, Table2 AS T2 WHERE T1.id=T2.id; U N I T3 : M Y S Q L B A S I C S Joining Tables Using AS
  • 10. U N I T3 : M Y S Q L B A S I C S Joining Tables SELECT name,author,title FROM customers JOIN classics ON customers.isbn=classics.isbn; JOIN ON Using AS SELECT name,author,title FROM customers AS cust, classics AS class WHERE cust.isbn=class.isbn; + + + + | name | author | title | + + + + | Joe Bloggs | Charles Dickens | The Old Curiosity Shop | | Mary Smith | Jane Austen | Pride and Prejudice | | Jack Wilson | Charles Darwin | The Origin of Species | + - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - +
  • 11. U N I T 3 : M Y S Q L B A S I C S Joining Tables QUERIES?