SlideShare a Scribd company logo
Muhammad Umair
Oracle Database 11g Developer Track
› Cartesian Product
– A Cartesian product is formed when:
› A join condition is invalid
› All row of table A are joined with table B all rows
– To avoid Cartesian product always include a valid join condition in
where clause
› Types Of Joins
› Cross Join
› Natural Join
› Equijoin
› Non-Equijoin
› Self Join
› Inner Join
› Outer Join
› Cross join
– Same as Cartesian product
– SELECT employees.employee_name, departments.department_name
– FROM employees
– Corss Join departments;
› Natural join
– Join all columns in the two tables that have the same name.
– Selects rows from the two tables that have equal values in all matches
columns.
– If the columns having the same names but different datatypes, error
will return
– SELECT employees.employee_name, departments.department_name
– FROM employees
– Natural Join departments;
› Equijoin
– SELECT employees.employee_name, departments.department_name
– FROM employees,departments
– WHERE employees.department_id = departments.department_id;
› Using Operatores in Equijoin
– SELECT employees.employee_name, departments.department_name
– FROM employees,departments
– WHERE employees.department_id = departments.department_id
– AND employee_id = 105;
› More Then Two Tables
– SELECT employees.employee_name,
departments.department_name,city
– FROM employees,departments,locations
– WHERE employees.department_id = departments.department_id
– AND departments.location_id = location.location_id;
;
› Non-Equijoin
– SELECT e.first_name,j.grade_level
– FROM employees e, job_grades j
– WHER e.salary
– BETWEEN j.lowest_sal AND j.highest_sal;
› Self Join
– SELECT w.first_name ||’ works for ’|| e.first_name
– FROM employees w, employees e
– WHER e.manager_id = m.employee_id
› INNER JOIN
– Returns all rows when there is at least one match in BOTH tables
– SELECT Customers.CustomerName, Orders.OrderID
FROM Customers
INNER JOIN Orders
ON Customers.CustomerID=Orders.CustomerID;
› OUTER JOIN
– You use outer join to see rows that do not meet the join condition.
– LEFT JOIN
› Return all rows from the left table, and the matched rows from the right table
– RIGHT JOIN
› Return all rows from the right table, and the matched rows from the left table
– FULL JOIN
– Return all rows when there is a match in ONE of the tables
Left JOIN
Right JOIN
Full JOIN
› Left JOIN
– SELECT e.last_name, e.department_id, d.department_name
– FROM employees e
– LEFT OUTER JOIN department d
– ON (e.department_id = d.epartment_id);
– SELECT e.last_name, e.department_id, d.department_name
– FROM employees e, departments d
– WHERE e.department_id (+)= d.epartment_id;
› Right JOIN
– SELECT e.last_name, e.department_id, d.department_name
– FROM employees e
– Right OUTER JOIN department d
– ON (e.department_id = d.epartment_id);
– SELECT e.last_name, e.department_id, d.department_name
– FROM employees e, departments d
– WHERE e.department_id = d.epartment_id (+);
› Full Outer JOIN
– SELECT e.last_name, e.department_id, d.department_name
– FROM employees e
– FULL OUTER JOIN department d
– ON (e.department_id = d.epartment_id);

More Related Content

PPT
PPT
Using subqueries to solve queries
PPT
Using the set operators
PPT
Les07 (using the set operators)
PPT
PPTX
Sql joins
PPT
PPTX
Oracle: Joins
Using subqueries to solve queries
Using the set operators
Les07 (using the set operators)
Sql joins
Oracle: Joins

What's hot (20)

PPT
Join sql
PPT
Types Of Join In Sql Server - Join With Example In Sql Server
PPT
Sql join
PPSX
Join query
PPTX
SQL JOIN
PDF
SQL Practice Question set
PPT
SQL Introduction to displaying data from multiple tables
PPTX
Sql joins inner join self join outer joins
PPTX
MS Sql Server: Joining Databases
PPT
SQL Joinning.Database
PPT
Oracle sql joins
PPTX
Joins And Its Types
PPTX
Lab4 join - all types listed
PPTX
MULTIPLE TABLES
DOC
SQL Joins
PPT
Displaying data from multiple tables
PPTX
MySQL JOIN & UNION
PDF
SQL JOINS
PPTX
Join sql
Types Of Join In Sql Server - Join With Example In Sql Server
Sql join
Join query
SQL JOIN
SQL Practice Question set
SQL Introduction to displaying data from multiple tables
Sql joins inner join self join outer joins
MS Sql Server: Joining Databases
SQL Joinning.Database
Oracle sql joins
Joins And Its Types
Lab4 join - all types listed
MULTIPLE TABLES
SQL Joins
Displaying data from multiple tables
MySQL JOIN & UNION
SQL JOINS
Ad

Viewers also liked (16)

PPTX
Database intro
PPT
Database intro
PPT
Database Relationships
PPTX
Relational database intro for marketers
PPTX
SQL Join Basic
PDF
Course intro
PPTX
Intro To DataBase
PPTX
MySQL - Intro to Database
PDF
Everything about Database JOINS and Relationships
PPT
Database Relationships
PPTX
SQLite - Overview
PPTX
SQLite: Light, Open Source Relational Database Management System
PPT
Database presentation
PPTX
joins in database
PPTX
Database - Entity Relationship Diagram (ERD)
PPTX
Introduction to database
Database intro
Database intro
Database Relationships
Relational database intro for marketers
SQL Join Basic
Course intro
Intro To DataBase
MySQL - Intro to Database
Everything about Database JOINS and Relationships
Database Relationships
SQLite - Overview
SQLite: Light, Open Source Relational Database Management System
Database presentation
joins in database
Database - Entity Relationship Diagram (ERD)
Introduction to database
Ad

Similar to Database Joins (20)

PPT
Les05 (Displaying Data from Multiple Table)
PPT
e computer notes - From multiple tables
PPT
Displaying Data from Multiple Tables - Oracle Data Base
PPT
Les04 Displaying Data from Multiple Tables.ppt
PPT
PDF
Advance database system(part 8)
PPT
PPTX
SQL JOINS- Reena P V
PPTX
SQL_JOINS_Presentation, INNER, OUTER Joins
PPTX
Querying_with_T-SQL_-_03 (1).pptx
PPTX
Querying_with_T-SQL_-_03.pptx
PPT
joins IN DATA BASE MANAGEMENT SYSTEMSppt
PPTX
Practical Joins Algorithms in database system
PPTX
Day-2 SQL Theory_V1.pptx
PDF
SQL Joins - Oracle SQL Fundamentals
PPTX
Presentation of Joins In Database
PDF
Joins in databases
PPTX
PPTX
REC-UNIT-2-DATABASEMANAGEMENTSYSTEMS.pptx
Les05 (Displaying Data from Multiple Table)
e computer notes - From multiple tables
Displaying Data from Multiple Tables - Oracle Data Base
Les04 Displaying Data from Multiple Tables.ppt
Advance database system(part 8)
SQL JOINS- Reena P V
SQL_JOINS_Presentation, INNER, OUTER Joins
Querying_with_T-SQL_-_03 (1).pptx
Querying_with_T-SQL_-_03.pptx
joins IN DATA BASE MANAGEMENT SYSTEMSppt
Practical Joins Algorithms in database system
Day-2 SQL Theory_V1.pptx
SQL Joins - Oracle SQL Fundamentals
Presentation of Joins In Database
Joins in databases
REC-UNIT-2-DATABASEMANAGEMENTSYSTEMS.pptx

More from Umair Shakir (17)

PPTX
Basic SQL Statments
PPTX
Introduction to Sql
PPTX
Services of dbms
PPTX
Constraints
PPTX
Task of db administrator
PPTX
Schema Objects
PPTX
Relationships
PPTX
Relational model
PPTX
Normalization
PPTX
Key and its different types
PPTX
Er model
PPTX
Introduction to basic database concepts
PPTX
Dbms and rdbms
PPTX
Database planning
PPTX
Conceptual database design
DOCX
Work Sheet
DOCX
G to a
Basic SQL Statments
Introduction to Sql
Services of dbms
Constraints
Task of db administrator
Schema Objects
Relationships
Relational model
Normalization
Key and its different types
Er model
Introduction to basic database concepts
Dbms and rdbms
Database planning
Conceptual database design
Work Sheet
G to a

Recently uploaded (20)

PDF
Types of Token_ From Utility to Security.pdf
PDF
Complete Guide to Website Development in Malaysia for SMEs
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PDF
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
PDF
Autodesk AutoCAD Crack Free Download 2025
PPTX
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
PDF
Time Tracking Features That Teams and Organizations Actually Need
PDF
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
PPTX
Monitoring Stack: Grafana, Loki & Promtail
PPTX
Trending Python Topics for Data Visualization in 2025
PDF
DNT Brochure 2025 – ISV Solutions @ D365
PPTX
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
DOCX
How to Use SharePoint as an ISO-Compliant Document Management System
PDF
Digital Systems & Binary Numbers (comprehensive )
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
Topaz Photo AI Crack New Download (Latest 2025)
PDF
iTop VPN Crack Latest Version Full Key 2025
PDF
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
PDF
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
PDF
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025
Types of Token_ From Utility to Security.pdf
Complete Guide to Website Development in Malaysia for SMEs
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
AI/ML Infra Meetup | Beyond S3's Basics: Architecting for AI-Native Data Access
Autodesk AutoCAD Crack Free Download 2025
AMADEUS TRAVEL AGENT SOFTWARE | AMADEUS TICKETING SYSTEM
Time Tracking Features That Teams and Organizations Actually Need
AI/ML Infra Meetup | LLM Agents and Implementation Challenges
Monitoring Stack: Grafana, Loki & Promtail
Trending Python Topics for Data Visualization in 2025
DNT Brochure 2025 – ISV Solutions @ D365
Log360_SIEM_Solutions Overview PPT_Feb 2020.pptx
How to Use SharePoint as an ISO-Compliant Document Management System
Digital Systems & Binary Numbers (comprehensive )
Designing Intelligence for the Shop Floor.pdf
Topaz Photo AI Crack New Download (Latest 2025)
iTop VPN Crack Latest Version Full Key 2025
EN-Survey-Report-SAP-LeanIX-EA-Insights-2025.pdf
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
DuckDuckGo Private Browser Premium APK for Android Crack Latest 2025

Database Joins

  • 1. Muhammad Umair Oracle Database 11g Developer Track
  • 2. › Cartesian Product – A Cartesian product is formed when: › A join condition is invalid › All row of table A are joined with table B all rows – To avoid Cartesian product always include a valid join condition in where clause
  • 3. › Types Of Joins › Cross Join › Natural Join › Equijoin › Non-Equijoin › Self Join › Inner Join › Outer Join
  • 4. › Cross join – Same as Cartesian product – SELECT employees.employee_name, departments.department_name – FROM employees – Corss Join departments;
  • 5. › Natural join – Join all columns in the two tables that have the same name. – Selects rows from the two tables that have equal values in all matches columns. – If the columns having the same names but different datatypes, error will return – SELECT employees.employee_name, departments.department_name – FROM employees – Natural Join departments;
  • 6. › Equijoin – SELECT employees.employee_name, departments.department_name – FROM employees,departments – WHERE employees.department_id = departments.department_id;
  • 7. › Using Operatores in Equijoin – SELECT employees.employee_name, departments.department_name – FROM employees,departments – WHERE employees.department_id = departments.department_id – AND employee_id = 105;
  • 8. › More Then Two Tables – SELECT employees.employee_name, departments.department_name,city – FROM employees,departments,locations – WHERE employees.department_id = departments.department_id – AND departments.location_id = location.location_id; ;
  • 9. › Non-Equijoin – SELECT e.first_name,j.grade_level – FROM employees e, job_grades j – WHER e.salary – BETWEEN j.lowest_sal AND j.highest_sal;
  • 10. › Self Join – SELECT w.first_name ||’ works for ’|| e.first_name – FROM employees w, employees e – WHER e.manager_id = m.employee_id
  • 11. › INNER JOIN – Returns all rows when there is at least one match in BOTH tables – SELECT Customers.CustomerName, Orders.OrderID FROM Customers INNER JOIN Orders ON Customers.CustomerID=Orders.CustomerID;
  • 12. › OUTER JOIN – You use outer join to see rows that do not meet the join condition. – LEFT JOIN › Return all rows from the left table, and the matched rows from the right table – RIGHT JOIN › Return all rows from the right table, and the matched rows from the left table – FULL JOIN – Return all rows when there is a match in ONE of the tables
  • 14. › Left JOIN – SELECT e.last_name, e.department_id, d.department_name – FROM employees e – LEFT OUTER JOIN department d – ON (e.department_id = d.epartment_id); – SELECT e.last_name, e.department_id, d.department_name – FROM employees e, departments d – WHERE e.department_id (+)= d.epartment_id;
  • 15. › Right JOIN – SELECT e.last_name, e.department_id, d.department_name – FROM employees e – Right OUTER JOIN department d – ON (e.department_id = d.epartment_id); – SELECT e.last_name, e.department_id, d.department_name – FROM employees e, departments d – WHERE e.department_id = d.epartment_id (+);
  • 16. › Full Outer JOIN – SELECT e.last_name, e.department_id, d.department_name – FROM employees e – FULL OUTER JOIN department d – ON (e.department_id = d.epartment_id);