Skip to main content


developerWorks  >  Information Management | XML  >

SQL and XQuery tutorial for IBM DB2, Part 3: SQL joins and unions

Complex queries that involve more than one relational table

developerWorks

Level: Introductory

Pat Moffatt (pmoffatt@ca.ibm.com), Information Management Program Manager, IBM Academic Initiative, IBM 
Bruce Creighton (bcreight@ca.ibm.com), Skills Segment Planner, IBM 
Jessica Cao , Training Tools Developer, IBM 

10 Aug 2006

Register now or sign in using your IBM ID and password.

This tutorial describes two ways to combine data from different tables in an IBM® DB2® database: by joining the tables with inner or outer joins and by using the UNION, EXCEPT, and INTERSECT operators, which take the intermediate result set from one query expression and combine it with the result set from another query expression. This tutorial is Part 3 of the SQL & XQuery tutorial for IBM DB2 series.

Prerequisites

This tutorial was written for DB2 Express-C 9 for UNIX®, Linux® and Windows® (formerly known as Viper). You should be familiar with DB2 and databases. It is preferable that you view tutorials one and two in this series before attempting this tutorial, part three.


System requirements

To use this tutorial to the fullest, you should have IBM DB2 9 installed. Download DB2 Express-C, a no-charge version of DB2 Express Edition for the community that offers the same core data features as DB2 Express Edtion and provides a solid base to build and deploy applications. You will also need to install the Aroma database, which can be downloaded in the tutorial.



Duration

Under 2 hours


Formats

html, pdf


About this tutorial

This tutorial describes two ways to combine data from different tables in an IBM DB2 database:

  • By joining the tables
  • By using the UNION, EXCEPT, and INTERSECT operators

The first part of this tutorial presents examples of inner and outer joins.

The second part illustrates how to combine data from different tables by using UNION, EXCEPT, and INTERSECT operators, which take the intermediate result set from one query expression and combine it with the result set from another query expression.

Share this....

digg Digg this story del.icio.us del.icio.us Slashdot Slashdot it!


Back to top


Document options

Document options requiring JavaScript are not displayed

Discuss


Learn and share!

Exchange know-how with your peers -- try our new Pass It Along beta app


More in this series:
SQL and XQuery tutorial for IBM DB2