57 lines
3.4 KiB
HTML
57 lines
3.4 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="Subqueries and search conditions" />
|
|
<meta name="abstract" content="A subquery can be part of a search condition." />
|
|
<meta name="description" content="A subquery can be part of a search condition." />
|
|
<meta name="DC.subject" content="subquery, search condition" />
|
|
<meta name="keywords" content="subquery, search condition" />
|
|
<meta name="DC.Relation" scheme="URI" content="rbafysubq.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="rbafysubnsearch" />
|
|
<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>Subqueries and search conditions</title>
|
|
</head>
|
|
<body id="rbafysubnsearch"><a name="rbafysubnsearch"><!-- --></a>
|
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
|
<h1 class="topictitle1">Subqueries and search conditions</h1>
|
|
<div><p>A subquery can be part of a search condition.</p>
|
|
<div class="section"><p>The search condition is in the form <em>operand operator operand</em>.
|
|
Either operand can be a subquery. In the following example, the first <strong>operand</strong> is
|
|
EMPNO and <strong>operator</strong> is IN. The search condition can be part of a WHERE
|
|
or HAVING clause. The clause can include more than one search condition that
|
|
contains a subquery. A search condition containing a subquery, like any other
|
|
search condition, can be enclosed in parentheses, can be preceded by the keyword
|
|
NOT, and can be linked to other search conditions through the keywords AND
|
|
and OR. For example, the WHERE clause of a query can look something like
|
|
this: </p>
|
|
<pre><strong>WHERE</strong> (subquery1) = X <strong>AND</strong> (Y > <strong>SOME</strong> (subquery2) <strong>OR</strong> Z = 100)</pre>
|
|
</div>
|
|
<div class="section"><p>Subqueries can also appear in the search conditions of other subqueries.
|
|
Such subqueries are said to be <strong>nested</strong> at some level of nesting. For
|
|
example, a subquery within a subquery within an outer-level SELECT is nested
|
|
at a nesting level of two. SQL allows nesting down to a nesting level of 32.</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafysubq.htm" title="Subqueries can help you to further refine your search conditions.">Subqueries in SELECT statements</a></div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html> |