SlideShare a Scribd company logo
SQL Fundamentals Oracle 11g
M U H A M M A D WA H E E D
O R AC L E DATA BA S E D E V E LO P E R
E M A I L : m .wa h e e d 3 6 6 8 @ g m a i l . co m
Lecture#7
SQL Joins/SELECT on Multiple Tables
Cartesian Product
2
Cartesian Product(cont’d)
•A Cartesian product is formed when
- A join condition is omitted
- A join condition is invalid
- All rows are joined to the all rows in second table
•To avoid it, use valid join condition in WHERE clause
3
Cartesian Product(cont’d)
•Example:
i- SELECT s.std_id, s.std_name,r.sub_id,r.obt_marks
FROM student s, result r;
ii- SELECT s.std_id, s.std_name,r.sub_id,r.obt_marks
FROM student s, result r
WHERE s.std_id = r.result_id;
4
Types of Joins
There are following commonly used joins:
•Equijoin
•Non-equijoin
•Outer join
•Self join
*Note: join condition is always mentioned in WHERE clause
5
Join Condition
6
Equijoin
7
Equijoin(cont’d)
•Example:
SELECT s.std_id, s.std_name, r.obt_marks
FROM student s, result r
WHERE s.std_id = r.std_id;
8
Equijoin(cont’d)
•Example(additional search with join):
SELECT s.std_id, s.std_name, r.obt_marks
FROM student s, result r
WHERE s.std_id = r.std_id
AND r.obt_marks>65;
9
Equijoin(cont’d)
•Example(more than two tables in join):
SELECT s.std_id, s.std_name,r.sub_id,r.obt_marks
FROM student s, result r, subject ss
WHERE s.std_id = r.std_id AND ss.sub_id = r.sub_id
AND r.obt_marks>65;
10
Non-Equijoin
•A join condition containing something other than equality
operator.
•Example:
SELECT t.tch_id, t.tch_name,t.salary,s.sal_grade
FROM teacher t, salary_grade s
WHERE t.salary BETWEEN s.min_sal AND s.max_sal;
11
Outer Join
•A join condition which is used to display those rows that doesn’t
meet join criteria.
•Outer join operator is plus sign ‘+’.
•There are two types of outer join
- Left outer join
- Right outer join
12
Outer Join(cont’d)
•Example(left join):
SELECT s.std_id, s.std_name, r.obt_marks
FROM student s, result r
WHERE s.std_id (+)= r.std_id;
•Example(right join):
SELECT s.std_id, s.std_name, s.dept_id
FROM student s, department d
WHERE s.dept_id = d.dept_id(+);
13
Self Join
•A join condition where a table having it’s own primary key
as foreign key in itself.
•Example: manager_id of employee table is employee_id
itself.
14
Self Join(cont’d)
•Example:
SELECT a.emp_id,a.emp_name,a.manager_id
FROM employee a,employee b
WHERE a.manager_id = b.emp_id;
15
Feedback/Suggestions?
Give your feedback at: m.waheed3668@gmail.com
The feedback I get is that my books are honest.
- Laurie Halse Anderson

More Related Content

What's hot (20)

PPT
Session 6
Shailendra Mathur
 
PPTX
MarcEdit Shelter-In-Place Webinar 7: Making Regular Expressions work for you ...
Terry Reese
 
PPTX
Basics of c programming cit r.sandhiya
Dr.Sandhiya Ravi
 
PPTX
STRUCTURE OF SQL QUERIES
VENNILAV6
 
PPT
20120810 tsql tips
LearningTech
 
PDF
C++ Templates_ Program to Swap Two Numbers Using Function Template - The Craz...
Rishikesh Agrawani
 
DOC
Unit 5 (1)
psaravanan1985
 
PPTX
Getting Started with Regular Expressions In MarcEdit
Terry Reese
 
PPTX
Select Clause
Dhirendra Chauhan
 
PPT
358 33 powerpoint-slides_6-strings_chapter-6
sumitbardhan
 
PPTX
Array & Exception Handling in C# (CSharp)
Sohanur63
 
PPTX
ADVANCE ITT BY PRASAD
PADYALAMAITHILINATHA
 
DOC
Mandatory sql functions for beginners
shravan kumar chelika
 
PPTX
concept of Array, 1D & 2D array
Sangani Ankur
 
PPTX
Arrays
RababaKollathodi
 
PPTX
Advanced SQL Webinar
Ram Kedem
 
PPTX
Arrays In C++
Awais Alam
 
PPT
358 33 powerpoint-slides_7-structures_chapter-7
sumitbardhan
 
MarcEdit Shelter-In-Place Webinar 7: Making Regular Expressions work for you ...
Terry Reese
 
Basics of c programming cit r.sandhiya
Dr.Sandhiya Ravi
 
STRUCTURE OF SQL QUERIES
VENNILAV6
 
20120810 tsql tips
LearningTech
 
C++ Templates_ Program to Swap Two Numbers Using Function Template - The Craz...
Rishikesh Agrawani
 
Unit 5 (1)
psaravanan1985
 
Getting Started with Regular Expressions In MarcEdit
Terry Reese
 
Select Clause
Dhirendra Chauhan
 
358 33 powerpoint-slides_6-strings_chapter-6
sumitbardhan
 
Array & Exception Handling in C# (CSharp)
Sohanur63
 
ADVANCE ITT BY PRASAD
PADYALAMAITHILINATHA
 
Mandatory sql functions for beginners
shravan kumar chelika
 
concept of Array, 1D & 2D array
Sangani Ankur
 
Advanced SQL Webinar
Ram Kedem
 
Arrays In C++
Awais Alam
 
358 33 powerpoint-slides_7-structures_chapter-7
sumitbardhan
 

Similar to SQL Joins - Oracle SQL Fundamentals (20)

PPT
Join sql
Vikas Gupta
 
PPT
Sql join
Vikas Gupta
 
PPT
Displaying Data from Multiple Tables - Oracle Data Base
Salman Memon
 
PPTX
SQL JOIN
Ritwik Das
 
PPTX
Database Joins
Umair Shakir
 
PPT
Les04 Displaying Data from Multiple Tables.ppt
DrZeeshanBhatti
 
PPT
App C
Sudharsan S
 
PPT
Oracle sql joins
redro
 
PPT
e computer notes - From multiple tables
ecomputernotes
 
PPT
joins IN DATA BASE MANAGEMENT SYSTEMSppt
Uma Kakarlapudi
 
PDF
Sql joins
Vivek Singh
 
PPTX
Sql joins
Gaurav Dhanwant
 
PDF
SQL JOINS
Swapnali Pawar
 
PPT
Les04
Vijay Kumar
 
PPT
Displaying data from multiple tables
Syed Zaid Irshad
 
PPTX
Joins
Mritunjay Sharma
 
PPT
Joins
VARSHAKUMARI49
 
PPTX
Lab4 join - all types listed
Balqees Al.Mubarak
 
PPTX
Day-2 SQL Theory_V1.pptx
uzmasulthana3
 
Join sql
Vikas Gupta
 
Sql join
Vikas Gupta
 
Displaying Data from Multiple Tables - Oracle Data Base
Salman Memon
 
SQL JOIN
Ritwik Das
 
Database Joins
Umair Shakir
 
Les04 Displaying Data from Multiple Tables.ppt
DrZeeshanBhatti
 
Oracle sql joins
redro
 
e computer notes - From multiple tables
ecomputernotes
 
joins IN DATA BASE MANAGEMENT SYSTEMSppt
Uma Kakarlapudi
 
Sql joins
Vivek Singh
 
Sql joins
Gaurav Dhanwant
 
SQL JOINS
Swapnali Pawar
 
Displaying data from multiple tables
Syed Zaid Irshad
 
Lab4 join - all types listed
Balqees Al.Mubarak
 
Day-2 SQL Theory_V1.pptx
uzmasulthana3
 
Ad

Recently uploaded (20)

PPTX
Smart Factory Monitoring IIoT in Machine and Production Operations.pptx
Rejig Digital
 
PDF
Understanding AI Optimization AIO, LLMO, and GEO
CoDigital
 
PPTX
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
PPTX
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 
PPTX
Practical Applications of AI in Local Government
OnBoard
 
PDF
Next level data operations using Power Automate magic
Andries den Haan
 
PDF
Simplify Your FME Flow Setup: Fault-Tolerant Deployment Made Easy with Packer...
Safe Software
 
PDF
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
PPTX
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
PDF
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
PDF
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
PDF
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 
PPTX
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
 
PDF
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
Fwdays
 
PDF
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 
PDF
Pipeline Industry IoT - Real Time Data Monitoring
Safe Software
 
PDF
Why aren't you using FME Flow's CPU Time?
Safe Software
 
PDF
FME as an Orchestration Tool with Principles From Data Gravity
Safe Software
 
PDF
Kubernetes - Architecture & Components.pdf
geethak285
 
PDF
Bridging CAD, IBM TRIRIGA & GIS with FME: The Portland Public Schools Case
Safe Software
 
Smart Factory Monitoring IIoT in Machine and Production Operations.pptx
Rejig Digital
 
Understanding AI Optimization AIO, LLMO, and GEO
CoDigital
 
Smarter Governance with AI: What Every Board Needs to Know
OnBoard
 
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 
Practical Applications of AI in Local Government
OnBoard
 
Next level data operations using Power Automate magic
Andries den Haan
 
Simplify Your FME Flow Setup: Fault-Tolerant Deployment Made Easy with Packer...
Safe Software
 
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
GDG Cloud Southlake #44: Eyal Bukchin: Tightening the Kubernetes Feedback Loo...
James Anderson
 
Hyderabad MuleSoft In-Person Meetup (June 21, 2025) Slides
Ravi Tamada
 
DoS Attack vs DDoS Attack_ The Silent Wars of the Internet.pdf
CyberPro Magazine
 
Paycifi - Programmable Trust_Breakfast_PPTXT
FinTech Belgium
 
''Taming Explosive Growth: Building Resilience in a Hyper-Scaled Financial Pl...
Fwdays
 
99 Bottles of Trust on the Wall — Operational Principles for Trust in Cyber C...
treyka
 
Pipeline Industry IoT - Real Time Data Monitoring
Safe Software
 
Why aren't you using FME Flow's CPU Time?
Safe Software
 
FME as an Orchestration Tool with Principles From Data Gravity
Safe Software
 
Kubernetes - Architecture & Components.pdf
geethak285
 
Bridging CAD, IBM TRIRIGA & GIS with FME: The Portland Public Schools Case
Safe Software
 
Ad

SQL Joins - Oracle SQL Fundamentals