ibm-information-center/dist/eclipse/plugins/i5OS.ic.sqlp_5.4.0.1/rbafyjoin.htm

89 lines
6.8 KiB
HTML
Raw Normal View History

2024-04-02 14:02:31 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="reference" />
<meta name="DC.Title" content="Join data from more than one table" />
<meta name="abstract" content="Sometimes the information you want to see is not in a single table. To form a row of the result table, you might want to retrieve some column values from one table and some column values from another table. You can retrieve and join column values from two or more tables into a single row." />
<meta name="description" content="Sometimes the information you want to see is not in a single table. To form a row of the result table, you might want to retrieve some column values from one table and some column values from another table. You can retrieve and join column values from two or more tables into a single row." />
<meta name="DC.subject" content="SELECT statement, joins, join, data from multiple tables, table, joining" />
<meta name="keywords" content="SELECT statement, joins, join, data from multiple tables, table, joining" />
<meta name="DC.Relation" scheme="URI" content="rbafytexas.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafyinj.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafyloj.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafyrojo.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafyexjo.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafycrojo.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafysimulatefoj.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafymjointypes.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="rbafyjoin" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Join data from more than one table</title>
</head>
<body id="rbafyjoin"><a name="rbafyjoin"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Join data from more than one table</h1>
<div><p>Sometimes the information you want to see is not in a single table.
To form a row of the result table, you might want to retrieve some column
values from one table and some column values from another table. You can retrieve
and join column values from two or more tables into a single row.</p>
<div class="section"><p>Several different types of joins are supported by <span class="keyword">DB2<sup>®</sup> UDB for iSeries™</span>:
inner join, left outer join, right outer join, left exception join, right
exception join, and cross join.</p>
</div>
<div class="section"><h4 class="sectiontitle">Usage notes on join operations</h4><div class="p">When you join two
or more tables, consider the following items:<ul><li>If there are common column names, you must qualify each common name with
the name of the table (or a correlation name). Column names that are unique
do not need to be qualified. However, the USING clause can be used in a join
to allow you to identify columns that exist in both tables without
specifying table names.</li>
<li>If you do not list the column names you want, but instead use SELECT *,
SQL returns rows that consist of all the columns of the first table, followed
by all the columns of the second table, and so on.</li>
<li>You must be authorized to select rows from each table or view specified
in the FROM clause.</li>
<li>The sort sequence is applied to all character, or UCS-2 or UTF-16 graphic
columns being joined.</li>
</ul>
</div>
</div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="rbafyinj.htm">Inner join</a></strong><br />
An inner join returns only the rows from each table that have matching values in the join columns. Any rows that do not have a match between the tables will not appear in the result table.</li>
<li class="ulchildlink"><strong><a href="rbafyloj.htm">Left outer join</a></strong><br />
A left outer join returns all the rows that an inner join returns plus one row for each of the other rows in the first table that did not have a match in the second table.</li>
<li class="ulchildlink"><strong><a href="rbafyrojo.htm">Right outer join</a></strong><br />
A right outer join returns all the rows that an inner join returns plus one row for each of the other rows in the second table that did not have a match in the first table. It is the same as a left outer join with the tables specified in the opposite order.</li>
<li class="ulchildlink"><strong><a href="rbafyexjo.htm">Exception join</a></strong><br />
A left exception join returns only the rows from the first table
that do <strong>not</strong> have a match in the second table. </li>
<li class="ulchildlink"><strong><a href="rbafycrojo.htm">Cross join</a></strong><br />
A cross join (or Cartesian Product join) returns a result table where each row from the first table is combined with each row from the second table.</li>
<li class="ulchildlink"><strong><a href="rbafysimulatefoj.htm">Simulate a full outer join</a></strong><br />
Like the left and right outer joins, a full outer join returns matching rows from both tables. However, a full outer join also returns non-matching rows from both tables; left and right.</li>
<li class="ulchildlink"><strong><a href="rbafymjointypes.htm">Multiple join types in one statement</a></strong><br />
There are times when more than two tables need to be joined to produce the result that you want.</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafytexas.htm" title="Learn a variety of ways of tailoring your query to gather data using the SELECT statement. One way to do this is to use the SELECT statement in a program to retrieve a specific row (for example, the row for an employee). Furthermore, you can use clauses to gather data in a specific way.">Retrieve data using the SELECT statement</a></div>
</div>
</div>
</body>
</html>