Oracle
  Home arrow Oracle arrow Page 5 - Multi-Table Queries with Oracle 10G XE
Dev Shed Forums 
Administration  
AJAX  
Apache  
BrainDump  
DHTML  
Flash  
Java  
JavaScript  
Multimedia  
MySQL  
Oracle  
Perl  
PHP  
Practices  
Python  
Reviews  
Security  
Style-Sheets  
Web Services  
XML  
Zend  
Zope  
Forums Sitemap 
IBM® developerWorks 
Sun Developer Network 
Dedicated Servers 
E-Commerce Hosting 
Linux Web Hosting 
Managed Hosting 
Small Business Hosting 
Actuate Whitepapers 
VeriSign Whitepapers 
VPS Hosting 
Weekly Newsletter

 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ORACLE

Multi-Table Queries with Oracle 10G XE
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 3 stars3 stars3 stars3 stars3 stars / 8
    2006-11-29

    Table of Contents:
  • Multi-Table Queries with Oracle 10G XE
  • Example 1. Single Table queries
  • Example 2. Two Tables: Join Employees and Departments tables
  • Example 3. Three tables: Employees, Departments, and Locations
  • Example 4. Four tables: Employees, Departments, Locations and Countries

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
    IBM developerWorks
     
    ADVERTISEMENT

    Stay one step ahead of the competition. Evaluate and give feedback on some of the hottest web development tools on the market today. Make your opinion heard! Click Here

    Multi-Table Queries with Oracle 10G XE - Example 4. Four tables: Employees, Departments, Locations and Countries


    (Page 5 of 5 )

    By similar reasoning, Oracle successively takes two tables at a time and creates the join as shown in the next picture. Observe the circuitous route to find the country name associated with an employee.

    select  "EMPLOYEES"."EMPLOYEE_ID" as "EMPLOYEE_ID",
    "EMPLOYEES"."LAST_NAME" as "LAST_NAME",
    "EMPLOYEES"."SALARY" as "SALARY",
    "DEPARTMENTS"."DEPARTMENT_NAME" as "DEPARTMENT_NAME",
    "LOCATIONS"."CITY" as "CITY",
    "COUNTRIES"."COUNTRY_NAME" as "COUNTRY_NAME" 
    from  "COUNTRIES" "COUNTRIES",
    "LOCATIONS" "LOCATIONS",
    "DEPARTMENTS" "DEPARTMENTS",
    "EMPLOYEES" "EMPLOYEES" 
    where "DEPARTMENTS"."DEPARTMENT_ID"="EMPLOYEES"."DEPARTMENT_ID" and
    "DEPARTMENTS"."LOCATION_ID"="LOCATIONS"."LOCATION_ID" and
    "LOCATIONS"."COUNTRY_ID"="COUNTRIES"."COUNTRY_ID" and
    "EMPLOYEES"."SALARY" > 9000 and "LOCATIONS"."CITY" !='Seattle'

    Summary

    Querying multiple tables was discussed using the Query Builder tool in Oracle 10G XE. Oracle's traditional syntax for the join was discussed, which places the join in the WHERE clause. This is also the syntax for joins generated by the Query Builder tool. Table aliases are implied in the queries built using the Query Builder. In order to use shortened names for table aliases the GUI generated code may have to be modified. While column aliases can be configured, the column names instead of the aliases are generated by the code in the order by clause. The use of Venn diagrams will aid considerably in understanding the joins.


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · This is a continuation of the usage of the query builder tool in Oracle 10g XE....
     

       

    ORACLE ARTICLES

    - Tuning PL/SQL Code
    - Debugging PL/SQL Code
    - Testing PL/SQL Code
    - Working With PL/SQL Code
    - Conditional Compilation for Oracle Database ...
    - Compile-Time Warnings for Oracle DB 10g
    - Compiling PL/SQL Code for an Oracle Database
    - Troubleshooting PL/SQL Code
    - Managing PL/SQL Code
    - Data Manipulation and More for HTML DB Appli...
    - Oracle Database Fundamentals
    - Adding Processes to HTML DB Applications
    - Adding Computations, Processes, and Validati...
    - Sub-templates and More with Oracle HTML DB
    - Focusing on Templates in Oracle HTML DB

    SlickEdit




    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway