SlideShare a Scribd company logo
*Property of STI K0019
Retrieving Data from
Several Tables
 What is a Join?
 Types of Join
*Property of STI K0019
What is a Join?
 A join is a collection of data from multiple tables.
 It combines two or more tables to retrieve data from
multiple tables.
 The primary keys and foreign keys are used to join related
tables to one another.
*Property of STI K0019
Types of Joins
 Equijoins or Inner Joins
 The equijoin or inner join combines two tables with a
common column which is usually the primary key.
 Syntax:
SELECT TABLE1.COLUMN1, TABLE2.COLUMN2...
FROM TABLE1, TABLE2 [, TABLE3 ]
WHERE TABLE1.COLUMN_NAME = TABLE2.COLUMN_NAME
[ AND TABLE1.COLUMN_NAME = TABLE3.COLUMN_NAME ]
*Property of STI K0019
Types of Joins
 Equijoins or Inner Joins (cont.)
 Example:
SELECT DISTINCT name, size,
order_items.quantity
FROM product, order_items
WHERE product.id = order_items.prod_id
AND product.quantity = order_items.quantity
*Property of STI K0019
Types of Joins
 Natural Joins
 The natural join removes duplicate columns in the joining
columns.
 Syntax:
SELECT TABLE1.*, TABLE2.COLUMN_NAME
[ TABLE3.COLUMN_NAME ]
FROM TABLE1, TABLE2 [ TABLE3 ]
WHERE TABLE1.COLUMN_NAME = TABLE2.COLUMN_NAME
[ AND TABLE1.COLUMN_NAME = TABLE3.COLUMN_NAME ]
*Property of STI K0019
Types of Joins
 Natural Joins (cont.)
 Example:
SELECT product.*,
order_items.quantity
FROM product, order_items
WHERE product.id = order_items.prod_id
*Property of STI K0019
Types of Joins
 Non-equijoins
 It combines two or more tables based on a specified column
value not equaling a specified column value in another table.
 Syntax:
SELECT TABLE1.*, TABLE2.COLUMN_NAME
[ TABLE3.COLUMN_NAME ]
FROM TABLE1, TABLE2 [, TABLE3 ]
WHERE TABLE1.COLUMN_NAME != TABLE2.COLUMN_NAME
[ AND TABLE1.COLUMN_NAME != TABLE2.COLUMN_NAME ]
*Property of STI K0019
Types of Joins
 Non-equijoins (cont.)
 Example:
SELECT EMPLOYEE_TBL.EMP_ID, SALARY_TBL.DATE_HIRE
FROM EMPLOYEE_TBL,
SALARY_TBL
WHERE EMPLOYEE_TBL.EMP_ID != SALARY_TBL.EMP_ID;
*Property of STI K0019
Types of Joins
 Outer Joins
 It produces all rows that exist in one table, even if there are
corresponding rows do not exist in the joined table.
 The left outer join preserves every row in the left-hand table.
 The right outer join preserves every row in the right-hand
table.
 A full outer join, preserves all rows from both tables.
*Property of STI K0019
Types of Joins
 Outer Joins (cont.)
 Syntax:
SELECT TABLE1.COLUMN_NAME, TABLE2.COLUMN_NAME
FROM TABLE1
{RIGHT | LEFT | FULL} [OUTER] JOIN
TABLE2 ON TABLE1.COLUMN_NAME = TABLE2.COLUMN_NAME
 Example:
SELECT EMPLOYEE_TBL.EMP_ID, SALARY_TBL.DATE_HIRE
FROM EMPLOYEE_TBL LEFT OUTER JOIN
SALARY_TBL ON EMPLOYEE_TBL.EMP_ID = SALARY_TBL.EMP_ID;
*Property of STI K0019
Types of Joins
 Self Joins
 The self join combines tables to itself.
 Syntax:
SELECT A.COLUMN_NAME, B.COLUMN_NAME,
[ C.COLUMN_NAME ]
FROM TABLE1 A, TABLE2 B [, TABLE3 C ]
WHERE A.COLUMN_NAME = B.COLUMN_NAME
[ AND A.COLUMN_NAME = C.COLUMN_NAME ]
*Property of STI K0019
Types of Joins
 Self Joins (cont.)
 Example:
SELECT A.LAST_NAME, B.LAST_NAME, A.FIRST_NAME
FROM EMPLOYEE_TBL A,
EMPLOYEE_TBL B
WHERE A.LAST_NAME = B.LAST_NAME;
*Property of STI K0019
Types of Joins
 Cross Joins
 It returns all possible combinations of rows from the two tables.
 Syntax:
SELECT *
FROM TABLE1 CROSS JOIN TABLE2
 Example:
SELECT *
FROM ORDER CROSS JOIN PURCHASE

More Related Content

PPTX
SQL JOINS- Reena P V
PPT
Sql joins
PPTX
Sql joins
PPTX
Sql(structured query language)
PPTX
SQL JOIN
PPTX
Inner join and outer join
PPSX
Join query
PPT
Displaying data from multiple tables
SQL JOINS- Reena P V
Sql joins
Sql joins
Sql(structured query language)
SQL JOIN
Inner join and outer join
Join query
Displaying data from multiple tables

What's hot (20)

PPTX
SQL : Structured Query Language
PPTX
Sql joins inner join self join outer joins
PPTX
MS Sql Server: Joining Databases
PPT
Join sql
PPT
Oracle sql joins
PPTX
Joins in SQL
PPTX
SQL Basics
PPTX
SQL UNION
PPT
SQL Joinning.Database
PPT
Types Of Join In Sql Server - Join With Example In Sql Server
PPTX
MySQL JOIN & UNION
PPTX
Oracle: Joins
PPT
Sql join
PPT
PPTX
Bootcamp sql fundamentals bootcamp_part1
DOC
Excel Formula and Function Basics
SQL : Structured Query Language
Sql joins inner join self join outer joins
MS Sql Server: Joining Databases
Join sql
Oracle sql joins
Joins in SQL
SQL Basics
SQL UNION
SQL Joinning.Database
Types Of Join In Sql Server - Join With Example In Sql Server
MySQL JOIN & UNION
Oracle: Joins
Sql join
Bootcamp sql fundamentals bootcamp_part1
Excel Formula and Function Basics
Ad

Similar to Query processing and data analysis (20)

PDF
SQL JOINS
PPTX
PPTX
V19 join method-c
PPT
joins IN DATA BASE MANAGEMENT SYSTEMSppt
PPTX
Practical Joins Algorithms in database system
PPTX
PPTX
Joins And Its Types
PPTX
Lab4 join - all types listed
PPTX
sql joins.pptx
PPTX
Join in SQL - Inner, Self, Outer Join
PPT
Displaying Data from Multiple Tables - Oracle Data Base
PPTX
Querying_with_T-SQL_-_03 (1).pptx
PPTX
Querying_with_T-SQL_-_03.pptx
PDF
SQL JOINS
PPT
Joins in SQL
PPT
PPT
Les04 Displaying Data from Multiple Tables.ppt
PPTX
Sql joins final
PDF
Kailas Manoj SQL Joins.pdfhvhggjbhbbjbjbbjbj
SQL JOINS
V19 join method-c
joins IN DATA BASE MANAGEMENT SYSTEMSppt
Practical Joins Algorithms in database system
Joins And Its Types
Lab4 join - all types listed
sql joins.pptx
Join in SQL - Inner, Self, Outer Join
Displaying Data from Multiple Tables - Oracle Data Base
Querying_with_T-SQL_-_03 (1).pptx
Querying_with_T-SQL_-_03.pptx
SQL JOINS
Joins in SQL
Les04 Displaying Data from Multiple Tables.ppt
Sql joins final
Kailas Manoj SQL Joins.pdfhvhggjbhbbjbjbbjbj
Ad

More from Anne Lee (20)

PDF
Week 17 slides 1 7 multidimensional, parallel, and distributed database
PDF
Data mining
PDF
Data warehousing
PDF
Database backup and recovery
PDF
Database monitoring and performance management
PDF
transportation and assignment models
PDF
Database Security Slide Handout
PDF
Database Security Handout
PDF
Database Security - IG
PDF
03 laboratory exercise 1 - WORKING WITH CTE
PDF
02 laboratory exercise 1 - RETRIEVING DATA FROM SEVERAL TABLES
PDF
01 laboratory exercise 1 - DESIGN A SIMPLE DATABASE APPLICATION
DOCX
Indexes - INSTRUCTOR'S GUIDE
PDF
07 ohp slides 1 - INDEXES
PDF
07 ohp slide handout 1 - INDEXES
PDF
Wk 16 ses 43 45 makrong kasanayan sa pagsusulat
PDF
Wk 15 ses 40 42 makrong kasanayan sa pagbabasa
PDF
Wk 13 ses 35 37 makrong kasanayan sa pagsasalita
PDF
Wk 12 ses 32 34 makrong kasanayan sa pakikinig
PDF
Wk 11 ses 29 31 konseptong pangkomunikasyon - FILIPINO 1
Week 17 slides 1 7 multidimensional, parallel, and distributed database
Data mining
Data warehousing
Database backup and recovery
Database monitoring and performance management
transportation and assignment models
Database Security Slide Handout
Database Security Handout
Database Security - IG
03 laboratory exercise 1 - WORKING WITH CTE
02 laboratory exercise 1 - RETRIEVING DATA FROM SEVERAL TABLES
01 laboratory exercise 1 - DESIGN A SIMPLE DATABASE APPLICATION
Indexes - INSTRUCTOR'S GUIDE
07 ohp slides 1 - INDEXES
07 ohp slide handout 1 - INDEXES
Wk 16 ses 43 45 makrong kasanayan sa pagsusulat
Wk 15 ses 40 42 makrong kasanayan sa pagbabasa
Wk 13 ses 35 37 makrong kasanayan sa pagsasalita
Wk 12 ses 32 34 makrong kasanayan sa pakikinig
Wk 11 ses 29 31 konseptong pangkomunikasyon - FILIPINO 1

Recently uploaded (20)

PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
assetexplorer- product-overview - presentation
PPTX
history of c programming in notes for students .pptx
PDF
Digital Systems & Binary Numbers (comprehensive )
PPTX
Advanced SystemCare Ultimate Crack + Portable (2025)
PDF
Autodesk AutoCAD Crack Free Download 2025
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
iTop VPN Free 5.6.0.5262 Crack latest version 2025
PDF
Navsoft: AI-Powered Business Solutions & Custom Software Development
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PPTX
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
PPTX
Operating system designcfffgfgggggggvggggggggg
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PDF
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
PPTX
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
PDF
Wondershare Filmora 15 Crack With Activation Key [2025
PDF
Salesforce Agentforce AI Implementation.pdf
PDF
iTop VPN Crack Latest Version Full Key 2025
PDF
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
assetexplorer- product-overview - presentation
history of c programming in notes for students .pptx
Digital Systems & Binary Numbers (comprehensive )
Advanced SystemCare Ultimate Crack + Portable (2025)
Autodesk AutoCAD Crack Free Download 2025
CHAPTER 2 - PM Management and IT Context
iTop VPN Free 5.6.0.5262 Crack latest version 2025
Navsoft: AI-Powered Business Solutions & Custom Software Development
wealthsignaloriginal-com-DS-text-... (1).pdf
WiFi Honeypot Detecscfddssdffsedfseztor.pptx
Operating system designcfffgfgggggggvggggggggg
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
Odoo Companies in India – Driving Business Transformation.pdf
Adobe Premiere Pro 2025 (v24.5.0.057) Crack free
Embracing Complexity in Serverless! GOTO Serverless Bengaluru
Wondershare Filmora 15 Crack With Activation Key [2025
Salesforce Agentforce AI Implementation.pdf
iTop VPN Crack Latest Version Full Key 2025
CCleaner Pro 6.38.11537 Crack Final Latest Version 2025

Query processing and data analysis

  • 1. *Property of STI K0019 Retrieving Data from Several Tables  What is a Join?  Types of Join
  • 2. *Property of STI K0019 What is a Join?  A join is a collection of data from multiple tables.  It combines two or more tables to retrieve data from multiple tables.  The primary keys and foreign keys are used to join related tables to one another.
  • 3. *Property of STI K0019 Types of Joins  Equijoins or Inner Joins  The equijoin or inner join combines two tables with a common column which is usually the primary key.  Syntax: SELECT TABLE1.COLUMN1, TABLE2.COLUMN2... FROM TABLE1, TABLE2 [, TABLE3 ] WHERE TABLE1.COLUMN_NAME = TABLE2.COLUMN_NAME [ AND TABLE1.COLUMN_NAME = TABLE3.COLUMN_NAME ]
  • 4. *Property of STI K0019 Types of Joins  Equijoins or Inner Joins (cont.)  Example: SELECT DISTINCT name, size, order_items.quantity FROM product, order_items WHERE product.id = order_items.prod_id AND product.quantity = order_items.quantity
  • 5. *Property of STI K0019 Types of Joins  Natural Joins  The natural join removes duplicate columns in the joining columns.  Syntax: SELECT TABLE1.*, TABLE2.COLUMN_NAME [ TABLE3.COLUMN_NAME ] FROM TABLE1, TABLE2 [ TABLE3 ] WHERE TABLE1.COLUMN_NAME = TABLE2.COLUMN_NAME [ AND TABLE1.COLUMN_NAME = TABLE3.COLUMN_NAME ]
  • 6. *Property of STI K0019 Types of Joins  Natural Joins (cont.)  Example: SELECT product.*, order_items.quantity FROM product, order_items WHERE product.id = order_items.prod_id
  • 7. *Property of STI K0019 Types of Joins  Non-equijoins  It combines two or more tables based on a specified column value not equaling a specified column value in another table.  Syntax: SELECT TABLE1.*, TABLE2.COLUMN_NAME [ TABLE3.COLUMN_NAME ] FROM TABLE1, TABLE2 [, TABLE3 ] WHERE TABLE1.COLUMN_NAME != TABLE2.COLUMN_NAME [ AND TABLE1.COLUMN_NAME != TABLE2.COLUMN_NAME ]
  • 8. *Property of STI K0019 Types of Joins  Non-equijoins (cont.)  Example: SELECT EMPLOYEE_TBL.EMP_ID, SALARY_TBL.DATE_HIRE FROM EMPLOYEE_TBL, SALARY_TBL WHERE EMPLOYEE_TBL.EMP_ID != SALARY_TBL.EMP_ID;
  • 9. *Property of STI K0019 Types of Joins  Outer Joins  It produces all rows that exist in one table, even if there are corresponding rows do not exist in the joined table.  The left outer join preserves every row in the left-hand table.  The right outer join preserves every row in the right-hand table.  A full outer join, preserves all rows from both tables.
  • 10. *Property of STI K0019 Types of Joins  Outer Joins (cont.)  Syntax: SELECT TABLE1.COLUMN_NAME, TABLE2.COLUMN_NAME FROM TABLE1 {RIGHT | LEFT | FULL} [OUTER] JOIN TABLE2 ON TABLE1.COLUMN_NAME = TABLE2.COLUMN_NAME  Example: SELECT EMPLOYEE_TBL.EMP_ID, SALARY_TBL.DATE_HIRE FROM EMPLOYEE_TBL LEFT OUTER JOIN SALARY_TBL ON EMPLOYEE_TBL.EMP_ID = SALARY_TBL.EMP_ID;
  • 11. *Property of STI K0019 Types of Joins  Self Joins  The self join combines tables to itself.  Syntax: SELECT A.COLUMN_NAME, B.COLUMN_NAME, [ C.COLUMN_NAME ] FROM TABLE1 A, TABLE2 B [, TABLE3 C ] WHERE A.COLUMN_NAME = B.COLUMN_NAME [ AND A.COLUMN_NAME = C.COLUMN_NAME ]
  • 12. *Property of STI K0019 Types of Joins  Self Joins (cont.)  Example: SELECT A.LAST_NAME, B.LAST_NAME, A.FIRST_NAME FROM EMPLOYEE_TBL A, EMPLOYEE_TBL B WHERE A.LAST_NAME = B.LAST_NAME;
  • 13. *Property of STI K0019 Types of Joins  Cross Joins  It returns all possible combinations of rows from the two tables.  Syntax: SELECT * FROM TABLE1 CROSS JOIN TABLE2  Example: SELECT * FROM ORDER CROSS JOIN PURCHASE