Edit D:\app\Administrator\product\11.2.0\dbhome_1\oc4j\j2ee\oc4j_applications\applications\em\em\online_help\tdddg\tdddg_selecting006.htm
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <script src="./callback.js" type="text/javascript"></script> <noscript>Your browser does not support JavaScript. This help page requires JavaScript to render correctly.</noscript> </head> <meta http-equiv="Content-Type" content="text/html; charset=us-ascii" /> <meta http-equiv="Content-Style-Type" content="text/css" /> <meta http-equiv="Content-Script-Type" content="text/javascript" /> <meta name="generator" content="Oracle DARB XHTML Converter (Mode = ohj/ohw) - Version 5.1.1 Build 005" /> <meta name="date" content="2009-04-21T9:46:23Z" /> <meta name="robots" content="noarchive" /> <meta name="doctitle" content="Selecting Data that Satisfies Specified Conditions" /> <meta name="relnum" content="11g Release 2 (11.2)" /> <meta name="partnum" content="E10766-01" /> <link rel="copyright" href="./dcommon/html/cpyr.htm" title="Copyright" type="text/html" /> <link rel="stylesheet" href="./dcommon/css/blafdoc.css" title="Oracle BLAFDoc" type="text/css" /> <link rel="contents" href="toc.htm" title="Contents" type="text/html" /> <link rel="prev" href="tdddg_selecting005.htm" title="Previous" type="text/html" /> <link rel="next" href="tdddg_selecting007.htm" title="Next" type="text/html" /> <title>Selecting Data that Satisfies Specified Conditions</title> </head> <body> <div class="zz-skip-header"><a href="#BEGIN">Skip Headers</a></div> <table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%"> <col width="86%" /> <col width="*" /> <tr valign="bottom"> <td align="left"></td> <td align="center"><a href="tdddg_selecting005.htm"><img width="24" height="24" src="./dcommon/gifs/leftnav.gif" alt="Previous" /><br /> <span class="icon">Previous</span></a> </td> <td align="center"><a href="tdddg_selecting007.htm"><img width="24" height="24" src="./dcommon/gifs/rightnav.gif" alt="Next" /><br /> <span class="icon">Next</span></a></td> </tr> </table> <p><a id="BCGBGBDC" name="BCGBGBDC"></a><a id="TDDDG22200" name="TDDDG22200"></a></p> <div class="sect1"><!-- infolevel="all" infotype="General" --> <h1>Selecting Data that Satisfies Specified Conditions</h1> <a name="BEGIN" id="BEGIN"></a> <p><a id="sthref105" name="sthref105"></a><a id="sthref106" name="sthref106"></a>To select only data that matches a specified condition, include the <a id="sthref107" name="sthref107"></a><a id="sthref108" name="sthref108"></a><code>WHERE</code> clause in the <code>SELECT</code> statement. The condition in the <code>WHERE</code> clause can be any SQL condition (for information about SQL conditions, see <a href="javascript:open('http://www.oracle.com/pls/db112/lookup?id=SQLRF005','newWindow').focus()"><span class="italic">Oracle Database SQL Language Reference</span></a>).</p> <p>The query in the following example selects data only for employees in department 90.</p> <div class="example"><a id="CEGCAGEC" name="CEGCAGEC"></a><a id="TDDDG132" name="TDDDG132"></a> <p class="titleinexample">Selecting Data from One Department</p> <pre xml:space="preserve" class="oac_no_warn"> SELECT FIRST_NAME, LAST_NAME, DEPARTMENT_ID FROM EMPLOYEES <span class="bold">WHERE DEPARTMENT_ID = 90</span>; </pre> <p>Result is similar to:</p> <pre xml:space="preserve" class="oac_no_warn"> FIRST_NAME LAST_NAME DEPARTMENT_ID -------------------- ------------------------- ------------- Steven King 90 Neena Kochhar 90 Lex De Haan 90 </pre></div> <!-- class="example" --> <p>The query in the following example selects data only for employees in departments 100, 110, and 120.</p> <div class="example"><a id="CEGDAAFC" name="CEGDAAFC"></a><a id="TDDDG133" name="TDDDG133"></a> <p class="titleinexample">Selecting Data from Specified Departments</p> <pre xml:space="preserve" class="oac_no_warn"> SELECT FIRST_NAME, LAST_NAME, DEPARTMENT_ID FROM EMPLOYEES <span class="bold">WHERE DEPARTMENT_ID IN (100, 110, 120)</span>; </pre> <p>Result is similar to:</p> <pre xml:space="preserve" class="oac_no_warn"> FIRST_NAME LAST_NAME DEPARTMENT_ID -------------------- ------------------------- ------------- John Chen 100 Daniel Faviet 100 William Gietz 110 Nancy Greenberg 100 Shelley Higgins 110 Luis Popp 100 Ismael Sciarra 100 Jose Manuel Urman 100 8 rows selected. </pre> <p>There are no employees in department 120.</p> </div> <!-- class="example" --> <p>The query in the following example selects data only for employees whose last names start with "Ma".</p> <div class="example"><a id="CEGCHAFG" name="CEGCHAFG"></a><a id="TDDDG134" name="TDDDG134"></a> <p class="titleinexample">Selecting Data for Last Names that Start with the Same Substring</p> <pre xml:space="preserve" class="oac_no_warn"> SELECT FIRST_NAME, LAST_NAME FROM EMPLOYEES <span class="bold">WHERE LAST_NAME LIKE 'Ma%'</span>; </pre> <p>Result is similar to:</p> <pre xml:space="preserve" class="oac_no_warn"> FIRST_NAME LAST_NAME -------------------- ------------------------- Jason Mallin Steven Markle James Marlow Mattea Marvins Randall Matos Susan Mavris 6 rows selected. </pre></div> <!-- class="example" --> <p>The query in the following example selects data only for employees whose last names include "ma".</p> <div class="example"><a id="CEGDHBII" name="CEGDHBII"></a><a id="TDDDG135" name="TDDDG135"></a> <p class="titleinexample">Selecting Data for Last Names that Include the Same Substring</p> <pre xml:space="preserve" class="oac_no_warn"> SELECT FIRST_NAME, LAST_NAME FROM EMPLOYEES <span class="bold">WHERE LAST_NAME LIKE '%ma%'</span>; </pre> <p>Result is similar to:</p> <pre xml:space="preserve" class="oac_no_warn"> FIRST_NAME LAST_NAME -------------------- ------------------------- Sundita Kumar Jose Manuel Urman Shanta Vollman </pre></div> <!-- class="example" --> <p>The query in the following example tests for two conditions—whether the salary is at least 11000, and whether the commission percentage is not null.</p> <div class="example"><a id="CEGDADFJ" name="CEGDADFJ"></a><a id="TDDDG136" name="TDDDG136"></a> <p class="titleinexample">Selecting Data that Satisfies Two Conditions</p> <pre xml:space="preserve" class="oac_no_warn"> SELECT FIRST_NAME, LAST_NAME, SALARY, COMMISSION_PCT "%" FROM EMPLOYEES <span class="bold">WHERE (SALARY >= 11000) AND (COMMISSION_PCT IS NOT NULL)</span>; </pre> <p>Result is similar to:</p> <pre xml:space="preserve" class="oac_no_warn"> FIRST_NAME LAST_NAME SALARY % -------------------- ------------------------- ---------- ---------- John Russell 14000 .4 Karen Partners 13500 .3 Alberto Errazuriz 12000 .3 Gerald Cambrault 11000 .3 Lisa Ozer 11500 .25 Ellen Abel 11000 .3 6 rows selected. </pre></div> <!-- class="example" --> <div class="helpinfonotealso"> <h2>Related Topics</h2> <p><a href="javascript:open('http://www.oracle.com/pls/db112/lookup?id=SQLRF01702','newWindow').focus()"><span class="italic">Oracle Database SQL Language Reference</span></a> for more information about the <code>SELECT</code> statement, including the <code>WHERE</code> clause</p> <p><a href="javascript:open('http://www.oracle.com/pls/db112/lookup?id=SQLRF005','newWindow').focus()"><span class="italic">Oracle Database SQL Language Reference</span></a> for more information about SQL conditions</p> <p><a href="tdddg_selecting.htm#CHDHHAFA">Selecting Table Data</a></p> </div> </div> <!-- class="sect1" --> <!-- Start Footer --> <div class="footer"> <table class="simple oac_no_warn" summary="" cellspacing="0" cellpadding="0" width="100%"> <col width="86%" /> <col width="*" /> <tr> <td align="left"><span class="copyrightlogo">Copyright © 1996, 2009, Oracle and/or its affiliates. All rights reserved.</span><br /> <a href="./dcommon/html/cpyr.htm"><span class="copyrightlogo">Legal Notices</span></a></td> <td align="center"><a href="tdddg_selecting005.htm"><img width="24" height="24" src="./dcommon/gifs/leftnav.gif" alt="Previous" /><br /> <span class="icon">Previous</span></a> </td> <td align="center"><a href="tdddg_selecting007.htm"><img width="24" height="24" src="./dcommon/gifs/rightnav.gif" alt="Next" /><br /> <span class="icon">Next</span></a></td> </tr> </table> </div> <!-- class="footer" --> </body> </html>
Ms-Dos/Windows
Unix
Write backup
jsp File Browser version 1.2 by
www.vonloesch.de