forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com> Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
28 lines
3.4 KiB
HTML
28 lines
3.4 KiB
HTML
<a name="dli_08_0185"></a><a name="dli_08_0185"></a>
|
|
|
|
<h1 class="topictitle1">EXCEPT</h1>
|
|
<div id="body8662426"><div class="section" id="dli_08_0185__en-us_topic_0093946975_sd2a8177148244ec181d16321d81045fb"><h4 class="sectiontitle">Function</h4><p id="dli_08_0185__en-us_topic_0093946975_a072d429d40f248c3a8ffe7001b684918">This statement is used to return the difference set of two query results. </p>
|
|
</div>
|
|
<div class="section" id="dli_08_0185__en-us_topic_0093946975_s35ed492bb57c4f9eb1654de6827dd771"><h4 class="sectiontitle">Syntax</h4><div class="codecoloring" codetype="Sql" id="dli_08_0185__screen10299183120455"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="n">select_statement</span><span class="w"> </span><span class="k">EXCEPT</span><span class="w"> </span><span class="n">select_statement</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</div>
|
|
<div class="section" id="dli_08_0185__en-us_topic_0093946975_sfd79bf7dfdbd4333bec85943f72500ef"><h4 class="sectiontitle">Keywords</h4><p id="dli_08_0185__en-us_topic_0093946975_en-us_topic_0047959938_p74271016388">EXCEPT minus the sets. A EXCEPT B indicates to remove the records that exist in both A and B from A and return the results. The repeated records returned by EXCEPT are not removed by default. The number of columns returned by each SELECT statement must be the same. The types and names of columns do not have to be the same. </p>
|
|
</div>
|
|
<div class="section" id="dli_08_0185__en-us_topic_0093946975_s2f5d0927dd694bdd93380f402dda31a8"><h4 class="sectiontitle">Precautions</h4><p id="dli_08_0185__en-us_topic_0093946975_aca68edfc252041cca2754cbebdf541cf">Do not add brackets between multiple set operations, such as UNION, INTERSECT, and EXCEPT. Otherwise, an error is reported. </p>
|
|
</div>
|
|
<div class="section" id="dli_08_0185__en-us_topic_0093946975_s443a3bace61f4e6c9b7391a015421c93"><h4 class="sectiontitle">Example</h4><p id="dli_08_0185__en-us_topic_0093946975_a0c26e80e8bf34879a0ca388feed96b7d">To remove the records that exist in both <strong id="dli_08_0185__b3403143110271">SELECT * FROM student_1</strong> and <strong id="dli_08_0185__b20404131102716">SELECT * FROM student_2</strong> from <strong id="dli_08_0185__b114047311274">SELECT * FROM student_1</strong> and return the results, run the following statement:</p>
|
|
<div class="codecoloring" codetype="Sql" id="dli_08_0185__screen2017816442453"><div class="highlight"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span></pre></div></td><td class="code"><div><pre><span></span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">student_1</span><span class="w"> </span><span class="k">EXCEPT</span><span class="w"> </span><span class="k">SELECT</span><span class="w"> </span><span class="o">*</span><span class="w"> </span><span class="k">FROM</span><span class="w"> </span><span class="n">student_2</span><span class="p">;</span>
|
|
</pre></div></td></tr></table></div>
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dli_08_0182.html">Set Operations</a></div>
|
|
</div>
|
|
</div>
|
|
|