doc-exports/docs/dws/dev/dws_06_0028.html
Lu, Huayi a24ca60074 DWS DEVELOPER 811 version
Reviewed-by: Hasko, Vladimir <vladimir.hasko@t-systems.com>
Co-authored-by: Lu, Huayi <luhuayi@huawei.com>
Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
2023-01-19 13:37:49 +00:00

97 lines
8.8 KiB
HTML

<a name="EN-US_TOPIC_0000001145830677"></a><a name="EN-US_TOPIC_0000001145830677"></a>
<h1 class="topictitle1">Logical Operators</h1>
<div id="body8662426"><p id="EN-US_TOPIC_0000001145830677__a5aebd5a3252c497f944465be9d5d04fe">The usual logical operators include AND, OR, and NOT. SQL uses a three-valued logical system with true, false, and null, which represents "unknown". Their priorities are NOT &gt; AND &gt; OR.</p>
<p id="EN-US_TOPIC_0000001145830677__a1e1a9df59ad74c30be3b8d73f86500f2"><a href="#EN-US_TOPIC_0000001145830677__tddad89fc8a334725a6d9b2dca1969309">Table 1</a> lists operation rules, where a and b represent logical expressions.</p>
<div class="tablenoborder"><a name="EN-US_TOPIC_0000001145830677__tddad89fc8a334725a6d9b2dca1969309"></a><a name="tddad89fc8a334725a6d9b2dca1969309"></a><table cellpadding="4" cellspacing="0" summary="" id="EN-US_TOPIC_0000001145830677__tddad89fc8a334725a6d9b2dca1969309" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Operation rules</caption><thead align="left"><tr id="EN-US_TOPIC_0000001145830677__r5bb83b7cc68f4c36ab25c2662eeeb888"><th align="left" class="cellrowborder" valign="top" width="17.858214178582145%" id="mcps1.3.3.2.6.1.1"><p id="EN-US_TOPIC_0000001145830677__a0ad89c26bca04ba19149ec16566bebb7">a</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="16.91830816918308%" id="mcps1.3.3.2.6.1.2"><p id="EN-US_TOPIC_0000001145830677__a99e056373a8a48cc9d766124532d4441">b</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="22.187781221877813%" id="mcps1.3.3.2.6.1.3"><p id="EN-US_TOPIC_0000001145830677__a6eb5201cf6164d53814af931059a1152">a <strong id="EN-US_TOPIC_0000001145830677__b28106029">AND</strong> b Result</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="24.047595240475953%" id="mcps1.3.3.2.6.1.4"><p id="EN-US_TOPIC_0000001145830677__a23eb107825124e7daa9349185838e01d">a<em id="EN-US_TOPIC_0000001145830677__i26791430"> </em><strong id="EN-US_TOPIC_0000001145830677__b51228171">OR</strong><strong id="EN-US_TOPIC_0000001145830677__b10345062"> </strong>b Result</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="18.988101189881014%" id="mcps1.3.3.2.6.1.5"><p id="EN-US_TOPIC_0000001145830677__a728fd5755e174956a4ec1684c20a7c6e"><strong id="EN-US_TOPIC_0000001145830677__b16884906162743">NOT</strong> a Result</p>
</th>
</tr>
</thead>
<tbody><tr id="EN-US_TOPIC_0000001145830677__r13f1f77315934992b50293e2c2ea86d0"><td class="cellrowborder" valign="top" width="17.858214178582145%" headers="mcps1.3.3.2.6.1.1 "><p id="EN-US_TOPIC_0000001145830677__a678bfa26153643f99837a56aeb73b8f2">TRUE</p>
</td>
<td class="cellrowborder" valign="top" width="16.91830816918308%" headers="mcps1.3.3.2.6.1.2 "><p id="EN-US_TOPIC_0000001145830677__ae402f4a9a38246b2b955a1a657bd91de">TRUE</p>
</td>
<td class="cellrowborder" valign="top" width="22.187781221877813%" headers="mcps1.3.3.2.6.1.3 "><p id="EN-US_TOPIC_0000001145830677__a55809b3a598048e88abfefbe017eff99">TRUE</p>
</td>
<td class="cellrowborder" valign="top" width="24.047595240475953%" headers="mcps1.3.3.2.6.1.4 "><p id="EN-US_TOPIC_0000001145830677__ac4acdeffaa7941b5bc450f55f9e725eb">TRUE</p>
</td>
<td class="cellrowborder" valign="top" width="18.988101189881014%" headers="mcps1.3.3.2.6.1.5 "><p id="EN-US_TOPIC_0000001145830677__a7f50d8b4d8ea4d7f82a3fa7d48d02a87">FALSE</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001145830677__r0359b10d8f1d43b3b95adefdf3c2c10c"><td class="cellrowborder" valign="top" width="17.858214178582145%" headers="mcps1.3.3.2.6.1.1 "><p id="EN-US_TOPIC_0000001145830677__ad6e5f383e1dd452abc2199b8e5a7133c">TRUE</p>
</td>
<td class="cellrowborder" valign="top" width="16.91830816918308%" headers="mcps1.3.3.2.6.1.2 "><p id="EN-US_TOPIC_0000001145830677__af2894b59d2ac4dc1b242bb09830228bf">FALSE</p>
</td>
<td class="cellrowborder" valign="top" width="22.187781221877813%" headers="mcps1.3.3.2.6.1.3 "><p id="EN-US_TOPIC_0000001145830677__a1c2564aaa8d94f0fa07cc81b83f4201a">FALSE</p>
</td>
<td class="cellrowborder" valign="top" width="24.047595240475953%" headers="mcps1.3.3.2.6.1.4 "><p id="EN-US_TOPIC_0000001145830677__adb5e5b25c2784db0a28e6d86f22ed1bf">TRUE</p>
</td>
<td class="cellrowborder" valign="top" width="18.988101189881014%" headers="mcps1.3.3.2.6.1.5 "><p id="EN-US_TOPIC_0000001145830677__a98e48ede776e4b17b6f3e89e5fdb9da8">FALSE</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001145830677__r97588b79605e4c29842323f033a26d3c"><td class="cellrowborder" valign="top" width="17.858214178582145%" headers="mcps1.3.3.2.6.1.1 "><p id="EN-US_TOPIC_0000001145830677__a4fee44c6fbe24f61ba3cd6b5ba846181">TRUE</p>
</td>
<td class="cellrowborder" valign="top" width="16.91830816918308%" headers="mcps1.3.3.2.6.1.2 "><p id="EN-US_TOPIC_0000001145830677__aca79a7c922464160ac7aab726d78f52b">NULL</p>
</td>
<td class="cellrowborder" valign="top" width="22.187781221877813%" headers="mcps1.3.3.2.6.1.3 "><p id="EN-US_TOPIC_0000001145830677__a142a90bbc19e4e88bc1b3d6103d2fff2">NULL</p>
</td>
<td class="cellrowborder" valign="top" width="24.047595240475953%" headers="mcps1.3.3.2.6.1.4 "><p id="EN-US_TOPIC_0000001145830677__a3e761e46907b4bcd82e78ba9fc73573f">TRUE</p>
</td>
<td class="cellrowborder" valign="top" width="18.988101189881014%" headers="mcps1.3.3.2.6.1.5 "><p id="EN-US_TOPIC_0000001145830677__a3b599f8d7cf04630a55124f051823ca2">FALSE</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001145830677__r6b33fbeb4d66479e9e38f001eef48fbe"><td class="cellrowborder" valign="top" width="17.858214178582145%" headers="mcps1.3.3.2.6.1.1 "><p id="EN-US_TOPIC_0000001145830677__abf7178cde91a4200884208edaace4cf2">FALSE</p>
</td>
<td class="cellrowborder" valign="top" width="16.91830816918308%" headers="mcps1.3.3.2.6.1.2 "><p id="EN-US_TOPIC_0000001145830677__a2e5a2ee0beb0476cb0b9da2e2e339775">FALSE</p>
</td>
<td class="cellrowborder" valign="top" width="22.187781221877813%" headers="mcps1.3.3.2.6.1.3 "><p id="EN-US_TOPIC_0000001145830677__aaca930629e6d4a4d832450a5a7d19a07">FALSE</p>
</td>
<td class="cellrowborder" valign="top" width="24.047595240475953%" headers="mcps1.3.3.2.6.1.4 "><p id="EN-US_TOPIC_0000001145830677__aa20883a444d44ff583e010eca9e8546c">FALSE</p>
</td>
<td class="cellrowborder" valign="top" width="18.988101189881014%" headers="mcps1.3.3.2.6.1.5 "><p id="EN-US_TOPIC_0000001145830677__a4815cf70824b41f89e69831ab214a896">TRUE</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001145830677__r65b428afc3b84fb9ada2c6a10f77d799"><td class="cellrowborder" valign="top" width="17.858214178582145%" headers="mcps1.3.3.2.6.1.1 "><p id="EN-US_TOPIC_0000001145830677__a6344f619aa0e45c99455fdf92b8a980b">FALSE</p>
</td>
<td class="cellrowborder" valign="top" width="16.91830816918308%" headers="mcps1.3.3.2.6.1.2 "><p id="EN-US_TOPIC_0000001145830677__a6352e5d57abc497380f8cae20f8cc835">NULL</p>
</td>
<td class="cellrowborder" valign="top" width="22.187781221877813%" headers="mcps1.3.3.2.6.1.3 "><p id="EN-US_TOPIC_0000001145830677__ae87a3a54e64e424aac182d893062cd2f">FALSE</p>
</td>
<td class="cellrowborder" valign="top" width="24.047595240475953%" headers="mcps1.3.3.2.6.1.4 "><p id="EN-US_TOPIC_0000001145830677__a186a29dc7de9498ab51f98acfd219370">NULL</p>
</td>
<td class="cellrowborder" valign="top" width="18.988101189881014%" headers="mcps1.3.3.2.6.1.5 "><p id="EN-US_TOPIC_0000001145830677__aa71f7273907b400e8b6ccf569c9ad93c">TRUE</p>
</td>
</tr>
<tr id="EN-US_TOPIC_0000001145830677__r2592b39afa0e4bd2a36b4f889ecb1af3"><td class="cellrowborder" valign="top" width="17.858214178582145%" headers="mcps1.3.3.2.6.1.1 "><p id="EN-US_TOPIC_0000001145830677__a6ab69d04f1a24f7bb08ed438b1a8ad36">NULL</p>
</td>
<td class="cellrowborder" valign="top" width="16.91830816918308%" headers="mcps1.3.3.2.6.1.2 "><p id="EN-US_TOPIC_0000001145830677__ad4822811d9ca4f7dbe978487e8b27171">NULL</p>
</td>
<td class="cellrowborder" valign="top" width="22.187781221877813%" headers="mcps1.3.3.2.6.1.3 "><p id="EN-US_TOPIC_0000001145830677__a63e5cadb904d422bb6cf5cbf405c24b3">NULL</p>
</td>
<td class="cellrowborder" valign="top" width="24.047595240475953%" headers="mcps1.3.3.2.6.1.4 "><p id="EN-US_TOPIC_0000001145830677__a0fb13de8625d4d77907f31c64e7c6f10">NULL</p>
</td>
<td class="cellrowborder" valign="top" width="18.988101189881014%" headers="mcps1.3.3.2.6.1.5 "><p id="EN-US_TOPIC_0000001145830677__a248adafaf2c3469ea16723c5acb82171">NULL</p>
</td>
</tr>
</tbody>
</table>
</div>
<div class="note" id="EN-US_TOPIC_0000001145830677__n5c3950958ef047bcba8c12f2b72ac95b"><img src="public_sys-resources/note_3.0-en-us.png"><span class="notetitle"> </span><div class="notebody"><p id="EN-US_TOPIC_0000001145830677__af4c8a8ac573d45849f35de7de95661f9">The operators AND and OR are commutative, that is, you can switch the left and right operand without affecting the result.</p>
</div></div>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_06_0027.html">Functions and Operators</a></div>
</div>
</div>