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

69 lines
4.8 KiB
HTML

<?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="Inner join" />
<meta name="abstract" content="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." />
<meta name="description" content="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." />
<meta name="DC.subject" content="inner join" />
<meta name="keywords" content="inner join" />
<meta name="DC.Relation" scheme="URI" content="rbafyjoin.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafyinsyn.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafyinwhere.htm" />
<meta name="DC.Relation" scheme="URI" content="rbafyjoinusing.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="rbafyinj" />
<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>Inner join</title>
</head>
<body id="rbafyinj"><a name="rbafyinj"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Inner join</h1>
<div><p>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.</p>
<div class="section"><p>With an inner join, column values from one row of a table are
combined with column values from another row of another (or the same) table
to form a single row of data. SQL examines both tables specified for the join
to retrieve data from all the rows that meet the search condition for the
join. There are two ways of specifying an inner join: using the JOIN syntax,
and using the WHERE clause.</p>
</div>
<div class="section"><p>Suppose you want to retrieve the employee numbers, names, and
project numbers for all employees that are responsible for a project. In other
words, you want the <em>EMPNO</em> and <em>LASTNAME</em> columns from the CORPDATA.EMPLOYEE
table and the <em>PROJNO</em> column from the CORPDATA.PROJECT table. Only employees
with last names starting with 'S' or later should be considered. To find this
information, you need to join the two tables.</p>
</div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="rbafyinsyn.htm">Inner join using JOIN syntax</a></strong><br />
To use the inner join syntax, both of the tables you are joining are listed in the FROM clause, along with the join condition that applies to the tables.</li>
<li class="ulchildlink"><strong><a href="rbafyinwhere.htm">Inner join using the WHERE clause</a></strong><br />
Using the WHERE clause to perform this same join as in the Inner join using JOIN syntax topic is written by entering both the join condition and the additional selection condition in the WHERE clause.</li>
<li class="ulchildlink"><strong><a href="rbafyjoinusing.htm">Join data with the USING clause</a></strong><br />
You can use a shorthand method of defining join conditions with the USING clause. The USING clause is equivalent to a join condition where each column from the left table is compared to a column with the same name in the right table.</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafyjoin.htm" title="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.">Join data from more than one table</a></div>
</div>
</div>
</body>
</html>