{"id":2518,"date":"2020-12-17T15:54:56","date_gmt":"2020-12-17T07:54:56","guid":{"rendered":"https:\/\/www.gbase8.cn\/?p=2518"},"modified":"2021-03-05T13:43:47","modified_gmt":"2021-03-05T05:43:47","slug":"gbase-8a%e5%9c%a8not-in%e5%ad%90%e6%9f%a5%e8%af%a2%e4%b8%ad%e6%9c%89null%e5%80%bc%e6%97%b6%e8%bf%94%e5%9b%9e%e7%a9%ba%e7%bb%93%e6%9e%9c%e9%9b%86%e7%9a%84%e5%8e%9f%e5%9b%a0","status":"publish","type":"post","link":"https:\/\/www.gbase8.cn\/en\/2518","title":{"rendered":"\u5357\u5927\u901a\u7528GBase 8a\u5728not in\u5b50\u67e5\u8be2\u4e2d\u6709null\u503c\u65f6\u8fd4\u56de\u7a7a\u7ed3\u679c\u96c6\u7684\u539f\u56e0"},"content":{"rendered":"<p>GBase 8a\u5728\u6267\u884cnot in\u65f6\uff0c\u5982\u679c\u5d4c\u5957\u7684\u5b50\u67e5\u8be2\u91cc\u6709null\u503c\uff0c\u7ed3\u679c\u96c6\u662f\u7a7a\uff0c\u6ca1\u6709\u6ee1\u8db3\u6761\u4ef6\u7684\u8bb0\u5f55\u3002 \u56e0\u4e3a\u4ece\u7406\u8bba\u4e0a\u8bb2\uff0c null \u5230\u5e95\u662f\u6ca1\u5339\u914d\u4e0a\uff0c\u8fd8\u662f\u539f\u6765\u7684\u503c\u5c31\u662fnull,\u65e0\u6cd5\u533a\u5206\uff0c\u6240\u4ee5SQL\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u90fd\u662f\u8fd4\u56de\u7a7a\u3002<\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Directory Navigation<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2b355c57302\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewbox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewbox=\"0 0 24 24\" version=\"1.2\" baseprofile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2b355c57302\"  aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.gbase8.cn\/en\/2518\/#%E5%A4%8D%E7%8E%B0\" >\u590d\u73b0<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.gbase8.cn\/en\/2518\/#%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88\" >Solution<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E5%A4%8D%E7%8E%B0\"><\/span>\u590d\u73b0<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase&gt; select * from table1;\n+------+\n| id   |\n+------+\n|    1 |\n+------+\n1 row in set (Elapsed: 00:00:00.00)\n\ngbase&gt; select * from table2;\n+------+\n| id   |\n+------+\n|    1 |\n| NULL |\n|    2 |\n+------+\n3 rows in set (Elapsed: 00:00:00.00)\n\ngbase&gt; insert into table1 values(3);\nQuery OK, 1 row affected (Elapsed: 00:00:00.03)\n\ngbase&gt; select * from table1;\n+------+\n| id   |\n+------+\n|    1 |\n|    3 |\n+------+\n2 rows in set (Elapsed: 00:00:00.01)\n\ngbase&gt; select * from table2;\n+------+\n| id   |\n+------+\n|    1 |\n| NULL |\n|    2 |\n+------+\n3 rows in set (Elapsed: 00:00:00.00)\n\ngbase&gt; select * from table1 where id in(select id from table2);\n+------+\n| id   |\n+------+\n|    1 |\n+------+\n1 row in set (Elapsed: 00:00:00.01)\n\ngbase&gt; select * from table1 where not id in(select id from table2);\nEmpty set (Elapsed: 00:00:00.01)\n\ngbase&gt; select * from table1 where not id in(select id from table2 where id is not null);\n+------+\n| id   |\n+------+\n|    3 |\n+------+\n1 row in set (Elapsed: 00:00:00.02)\n<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\"><span class=\"ez-toc-section\" id=\"%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88\"><\/span>Solution<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>not in \u6539\u6210 not exists<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>gbase> select * from table1 where not exists (select id from table2 where table2.id=table1.id);\r\n+------+\r\n| id   |\r\n+------+\r\n|    3 |\r\n+------+\r\n1 row in set (Elapsed: 00:00:00.11)\r\n<\/code><\/pre>","protected":false},"excerpt":{"rendered":"<p>\u5357\u5927\u901a\u7528GBase 8a\u5728\u6267\u884cnot in\u65f6\uff0c\u5982\u679c\u5d4c\u5957\u7684\u5b50\u67e5\u8be2\u91cc\u6709null\u503c\uff0c\u7ed3\u679c\u96c6\u662f\u7a7a\uff0c\u6ca1\u6709\u6ee1\u8db3\u6761\u4ef6\u7684\u8bb0\u5f55\u3002 \u56e0\u4e3a\u4ece\u7406\u8bba\u4e0a\u8bb2\uff0c null \u5230\u5e95\u662f\u6ca1\u5339\u914d\u4e0a\uff0c\u8fd8\u662f\u539f\u6765\u7684\u503c\u5c31\u662fnull,\u65e0\u6cd5\u533a\u5206\uff0c\u6240\u4ee5SQL\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u90fd\u662f\u8fd4\u56de\u7a7a\u3002<\/p>","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-2518","post","type-post","status-publish","format-standard","hentry","category-gbase8a"],"_links":{"self":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/2518","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/comments?post=2518"}],"version-history":[{"count":2,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/2518\/revisions"}],"predecessor-version":[{"id":4973,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/posts\/2518\/revisions\/4973"}],"wp:attachment":[{"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/media?parent=2518"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/categories?post=2518"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gbase8.cn\/en\/wp-json\/wp\/v2\/tags?post=2518"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}