SlideShare una empresa de Scribd logo
1 de 44
Displaying Data  from Multiple Tables
Objectives ,[object Object],[object Object],[object Object],[object Object],[object Object]
Obtaining Data from Multiple Tables EMPLOYEES   DEPARTMENTS  … …
Cartesian Products ,[object Object],[object Object],[object Object],[object Object],[object Object]
Generating a Cartesian Product EMPLOYEES   (20 rows) DEPARTMENTS   (8 rows) … … Cartesian product:  20x8=160 rows
[object Object],[object Object],[object Object],[object Object],Types of Joins ,[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object]
Joining Tables Using Oracle Syntax ,[object Object],[object Object],[object Object],SELECT table1.column, table2.column FROM table1, table2 WHERE table1.column1  =  table2.column2;
What is an Equijoin? EMPLOYEES   DEPARTMENTS  … … Foreign key Primary key
Retrieving Records  with Equijoins SELECT employees.employee_id, employees.last_name,  employees.department_id, departments.department_id, departments.location_id FROM  employees, departments WHERE  employees.department_id = departments.department_id; …
Additional Search Conditions Using the  AND  Operator  EMPLOYEES   DEPARTMENTS   … …
Qualifying Ambiguous  Column Names ,[object Object],[object Object],[object Object]
Using Table Aliases ,[object Object],[object Object],SELECT e.employee_id, e.last_name, e.department_id, d.department_id, d.location_id FROM  employees e , departments d WHERE  e.department_id = d.department_id;
Joining More than Two Tables ,[object Object],EMPLOYEES   LOCATIONS   DEPARTMENTS   …
Non-Equijoins EMPLOYEES JOB_GRADES … Salary in the  EMPLOYEES   table must be between  lowest salary and highest  salary in the  JOB_GRADES table.
Retrieving Records  with Non-Equijoins SELECT e.last_name, e.salary, j.grade_level FROM  employees e, job_grades j WHERE  e.salary  BETWEEN j.lowest_sal AND j.highest_sal; …
Outer Joins EMPLOYEES DEPARTMENTS … There are no employees in department 190.
Outer Joins Syntax ,[object Object],[object Object],SELECT table1.column, table2.column FROM table1, table2 WHERE table1.column (+)   =  table2.column; SELECT table1.column, table2.column FROM table1, table2 WHERE table1.column  =  table2.column (+) ;
Using Outer Joins SELECT e.last_name, e.department_id, d.department_name FROM  employees e, departments d WHERE  e.department_id(+) = d.department_id ;   …
Self Joins EMPLOYEES (WORKER) EMPLOYEES (MANAGER) … … MANAGER_ID  in the  WORKER  table is equal to  EMPLOYEE_ID  in the  MANAGER  table.
Joining a Table to Itself SELECT worker.last_name || ' works for '  || manager.last_name FROM  employees worker, employees manager WHERE  worker.manager_id = manager.employee_id ; …
Practice 4, Part One: Overview ,[object Object],[object Object]
Joining Tables Using SQL: 1999 Syntax ,[object Object],SELECT table1.column, table2.column FROM table1 [CROSS JOIN  table2 ] | [NATURAL JOIN  table2 ] | [JOIN  table2  USING ( column_name )] | [JOIN  table2   ON( table1.column_name  =  table2.column_name )] | [LEFT|RIGHT|FULL OUTER JOIN  table2   ON ( table1.column_name  =  table2.column_name )];
Creating Cross Joins ,[object Object],[object Object],SELECT last_name, department_name FROM  employees CROSS JOIN departments ; …
Creating Natural Joins ,[object Object],[object Object],[object Object]
Retrieving Records with Natural Joins SELECT department_id, department_name, location_id, city FROM  departments NATURAL JOIN locations ;
Creating Joins with the  USING  Clause ,[object Object],[object Object],[object Object],[object Object]
Retrieving Records with the  USING  Clause SELECT e.employee_id, e.last_name, d.location_id FROM  employees e JOIN departments d USING (department_id) ; …
Creating Joins with the  ON  Clause ,[object Object],[object Object],[object Object],[object Object]
Retrieving Records with the  ON  Clause SELECT e.employee_id, e.last_name, e.department_id,  d.department_id, d.location_id FROM  employees e JOIN departments d ON  (e.department_id = d.department_id); …
Creating Three-Way Joins with  the  ON  Clause SELECT employee_id, city, department_name FROM  employees e  JOIN  departments d ON  d.department_id = e.department_id  JOIN  locations l ON  d.location_id = l.location_id; …
INNER  Versus  OUTER  Joins ,[object Object],[object Object],[object Object]
LEFT OUTER JOIN SELECT e.last_name, e.department_id, d.department_name FROM  employees e LEFT OUTER JOIN departments d ON  (e.department_id = d.department_id) ; …
RIGHT OUTER JOIN SELECT e.last_name, e.department_id, d.department_name FROM  employees e RIGHT OUTER JOIN departments d ON  (e.department_id = d.department_id) ; …
FULL OUTER JOIN SELECT e.last_name, e.department_id, d.department_name FROM  employees e FULL OUTER JOIN departments d ON  (e.department_id = d.department_id) ; …
Additional Conditions SELECT e.employee_id, e.last_name, e.department_id,  d.department_id, d.location_id FROM  employees e JOIN departments d ON  (e.department_id = d.department_id) AND  e.manager_id = 149 ;
Summary ,[object Object],[object Object],[object Object],[object Object]
Practice 4, Part Two: Overview ,[object Object],[object Object],[object Object],[object Object]
 
 
 
 
 
 
 

Más contenido relacionado

La actualidad más candente

La actualidad más candente (18)

e computer notes - Using set operator
e computer notes - Using set operatore computer notes - Using set operator
e computer notes - Using set operator
 
MULTIPLE TABLES
MULTIPLE TABLES MULTIPLE TABLES
MULTIPLE TABLES
 
SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables  SQL Introduction to displaying data from multiple tables
SQL Introduction to displaying data from multiple tables
 
Oracle sql joins
Oracle sql joinsOracle sql joins
Oracle sql joins
 
e computer notes - Advanced subqueries
e computer notes - Advanced subqueriese computer notes - Advanced subqueries
e computer notes - Advanced subqueries
 
SQL- Introduction to MySQL
SQL- Introduction to MySQLSQL- Introduction to MySQL
SQL- Introduction to MySQL
 
Database Joins
Database JoinsDatabase Joins
Database Joins
 
Dump Answers
Dump AnswersDump Answers
Dump Answers
 
Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)Les09 (using ddl statements to create and manage tables)
Les09 (using ddl statements to create and manage tables)
 
Oracle: Joins
Oracle: JoinsOracle: Joins
Oracle: Joins
 
Restricting and sorting data
Restricting and sorting dataRestricting and sorting data
Restricting and sorting data
 
1 z0 047
1 z0 0471 z0 047
1 z0 047
 
Les18
Les18Les18
Les18
 
SQL(database)
SQL(database)SQL(database)
SQL(database)
 
Les04
Les04Les04
Les04
 
Les04
Les04Les04
Les04
 
Les02
Les02Les02
Les02
 
Oracle OCP 1Z0-007题库
Oracle OCP 1Z0-007题库Oracle OCP 1Z0-007题库
Oracle OCP 1Z0-007题库
 

Destacado (8)

Les19
Les19Les19
Les19
 
Les03
Les03Les03
Les03
 
Les06
Les06Les06
Les06
 
Les05
Les05Les05
Les05
 
Les08
Les08Les08
Les08
 
Les20
Les20Les20
Les20
 
Advanced functions in PL SQL
Advanced functions in PL SQLAdvanced functions in PL SQL
Advanced functions in PL SQL
 
Oracle sql developer_slides
Oracle sql developer_slidesOracle sql developer_slides
Oracle sql developer_slides
 

Similar a Les04

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
 
Displaying data from multiple tables
Displaying data from multiple tablesDisplaying data from multiple tables
Displaying data from multiple tablesSyed Zaid Irshad
 
e computer notes - From multiple tables
e computer notes - From multiple tablese computer notes - From multiple tables
e computer notes - From multiple tablesecomputernotes
 
Day-2 SQL Theory_V1.pptx
Day-2 SQL Theory_V1.pptxDay-2 SQL Theory_V1.pptx
Day-2 SQL Theory_V1.pptxuzmasulthana3
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive TechandMate
 
Displaying Data from Multiple Tables - Oracle Data Base
Displaying Data from Multiple Tables - Oracle Data BaseDisplaying Data from Multiple Tables - Oracle Data Base
Displaying Data from Multiple Tables - Oracle Data BaseSalman Memon
 
SQLSERVERQUERIES.pptx
SQLSERVERQUERIES.pptxSQLSERVERQUERIES.pptx
SQLSERVERQUERIES.pptxssuser6bf2d1
 
Interacting with Oracle Database
Interacting with Oracle DatabaseInteracting with Oracle Database
Interacting with Oracle DatabaseChhom Karath
 
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) .pptxjainendraKUMAR55
 
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 JoinSouma Maiti
 

Similar a Les04 (20)

Les05 (Displaying Data from Multiple Table)
Les05 (Displaying Data from Multiple Table)Les05 (Displaying Data from Multiple Table)
Les05 (Displaying Data from Multiple Table)
 
App C
App CApp C
App C
 
Displaying data from multiple tables
Displaying data from multiple tablesDisplaying data from multiple tables
Displaying data from multiple tables
 
e computer notes - From multiple tables
e computer notes - From multiple tablese computer notes - From multiple tables
e computer notes - From multiple tables
 
Day-2 SQL Theory_V1.pptx
Day-2 SQL Theory_V1.pptxDay-2 SQL Theory_V1.pptx
Day-2 SQL Theory_V1.pptx
 
Join sql
Join sqlJoin sql
Join sql
 
Sql join
Sql  joinSql  join
Sql join
 
SQL Server Learning Drive
SQL Server Learning Drive SQL Server Learning Drive
SQL Server Learning Drive
 
Joins.ppt
Joins.pptJoins.ppt
Joins.ppt
 
0808.pdf
0808.pdf0808.pdf
0808.pdf
 
0808.pdf
0808.pdf0808.pdf
0808.pdf
 
Lab4 join - all types listed
Lab4   join - all types listedLab4   join - all types listed
Lab4 join - all types listed
 
Joins in SQL
Joins in SQLJoins in SQL
Joins in SQL
 
Module03
Module03Module03
Module03
 
Displaying Data from Multiple Tables - Oracle Data Base
Displaying Data from Multiple Tables - Oracle Data BaseDisplaying Data from Multiple Tables - Oracle Data Base
Displaying Data from Multiple Tables - Oracle Data Base
 
SQLSERVERQUERIES.pptx
SQLSERVERQUERIES.pptxSQLSERVERQUERIES.pptx
SQLSERVERQUERIES.pptx
 
Interacting with Oracle Database
Interacting with Oracle DatabaseInteracting with Oracle Database
Interacting with Oracle Database
 
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
 
SQL report
SQL reportSQL report
SQL report
 
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
 

Más de Vijay Kumar (9)

Les17
Les17Les17
Les17
 
Les16
Les16Les16
Les16
 
Les14
Les14Les14
Les14
 
Les13
Les13Les13
Les13
 
Les12
Les12Les12
Les12
 
Les10
Les10Les10
Les10
 
Les11
Les11Les11
Les11
 
Les07
Les07Les07
Les07
 
Les09
Les09Les09
Les09
 

Último

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 

Último (20)

Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 

Les04

  • 1. Displaying Data from Multiple Tables
  • 2.
  • 3. Obtaining Data from Multiple Tables EMPLOYEES DEPARTMENTS … …
  • 4.
  • 5. Generating a Cartesian Product EMPLOYEES (20 rows) DEPARTMENTS (8 rows) … … Cartesian product: 20x8=160 rows
  • 6.
  • 7.
  • 8. What is an Equijoin? EMPLOYEES DEPARTMENTS … … Foreign key Primary key
  • 9. Retrieving Records with Equijoins SELECT employees.employee_id, employees.last_name, employees.department_id, departments.department_id, departments.location_id FROM employees, departments WHERE employees.department_id = departments.department_id; …
  • 10. Additional Search Conditions Using the AND Operator EMPLOYEES DEPARTMENTS … …
  • 11.
  • 12.
  • 13.
  • 14. Non-Equijoins EMPLOYEES JOB_GRADES … Salary in the EMPLOYEES table must be between lowest salary and highest salary in the JOB_GRADES table.
  • 15. Retrieving Records with Non-Equijoins SELECT e.last_name, e.salary, j.grade_level FROM employees e, job_grades j WHERE e.salary BETWEEN j.lowest_sal AND j.highest_sal; …
  • 16. Outer Joins EMPLOYEES DEPARTMENTS … There are no employees in department 190.
  • 17.
  • 18. Using Outer Joins SELECT e.last_name, e.department_id, d.department_name FROM employees e, departments d WHERE e.department_id(+) = d.department_id ; …
  • 19. Self Joins EMPLOYEES (WORKER) EMPLOYEES (MANAGER) … … MANAGER_ID in the WORKER table is equal to EMPLOYEE_ID in the MANAGER table.
  • 20. Joining a Table to Itself SELECT worker.last_name || ' works for ' || manager.last_name FROM employees worker, employees manager WHERE worker.manager_id = manager.employee_id ; …
  • 21.
  • 22.
  • 23.
  • 24.
  • 25. Retrieving Records with Natural Joins SELECT department_id, department_name, location_id, city FROM departments NATURAL JOIN locations ;
  • 26.
  • 27. Retrieving Records with the USING Clause SELECT e.employee_id, e.last_name, d.location_id FROM employees e JOIN departments d USING (department_id) ; …
  • 28.
  • 29. Retrieving Records with the ON Clause SELECT e.employee_id, e.last_name, e.department_id, d.department_id, d.location_id FROM employees e JOIN departments d ON (e.department_id = d.department_id); …
  • 30. Creating Three-Way Joins with the ON Clause SELECT employee_id, city, department_name FROM employees e JOIN departments d ON d.department_id = e.department_id JOIN locations l ON d.location_id = l.location_id; …
  • 31.
  • 32. LEFT OUTER JOIN SELECT e.last_name, e.department_id, d.department_name FROM employees e LEFT OUTER JOIN departments d ON (e.department_id = d.department_id) ; …
  • 33. RIGHT OUTER JOIN SELECT e.last_name, e.department_id, d.department_name FROM employees e RIGHT OUTER JOIN departments d ON (e.department_id = d.department_id) ; …
  • 34. FULL OUTER JOIN SELECT e.last_name, e.department_id, d.department_name FROM employees e FULL OUTER JOIN departments d ON (e.department_id = d.department_id) ; …
  • 35. Additional Conditions SELECT e.employee_id, e.last_name, e.department_id, d.department_id, d.location_id FROM employees e JOIN departments d ON (e.department_id = d.department_id) AND e.manager_id = 149 ;
  • 36.
  • 37.
  • 38.  
  • 39.  
  • 40.  
  • 41.  
  • 42.  
  • 43.  
  • 44.  

Notas del editor

  1. Schedule: Timing Topic 55 minutes Lecture 55 minutes Practice 110 minutes Total