{"id":160145,"date":"2024-11-03T20:39:16","date_gmt":"2024-11-03T12:39:16","guid":{"rendered":"https:\/\/server.hk\/cnblog\/160145\/"},"modified":"2024-11-03T20:39:17","modified_gmt":"2024-11-03T12:39:17","slug":"oceanbase-%e6%95%99%e7%a8%8b%ef%bc%9aoceanbase-intersect","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/160145\/","title":{"rendered":"OceanBase \u6559\u7a0b\uff1aOceanBase INTERSECT"},"content":{"rendered":"<h1 id=\"oceanbase-%e6%95%99%e7%a8%8b%ef%bc%9aoceanbase-intersect-aaXVLblUzL\">OceanBase \u6559\u7a0b\uff1aOceanBase INTERSECT<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\u4e2d\uff0cOceanBase \u4f5c\u70ba\u4e00\u500b\u9ad8\u6027\u80fd\u7684\u5206\u4f48\u5f0f\u6578\u64da\u5eab\uff0c\u8d8a\u4f86\u8d8a\u53d7\u5230\u958b\u767c\u8005\u548c\u4f01\u696d\u7684\u9752\u775e\u3002\u5b83\u4e0d\u50c5\u652f\u6301\u9ad8\u4e26\u767c\u7684\u8b80\u5beb\u64cd\u4f5c\uff0c\u9084\u5177\u5099\u826f\u597d\u7684\u64f4\u5c55\u6027\u548c\u5bb9\u932f\u80fd\u529b\u3002\u672c\u6587\u5c07\u91cd\u9ede\u4ecb\u7d39 OceanBase \u4e2d\u7684 INTERSECT \u64cd\u4f5c\uff0c\u5e6b\u52a9\u8b80\u8005\u66f4\u597d\u5730\u7406\u89e3\u5176\u7528\u6cd5\u53ca\u61c9\u7528\u5834\u666f\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af-intersect%ef%bc%9f-aaXVLblUzL\">\u4ec0\u9ebc\u662f INTERSECT\uff1f<\/h2>\n<p>INTERSECT \u662f SQL \u4e2d\u7684\u4e00\u500b\u96c6\u5408\u64cd\u4f5c\uff0c\u7528\u65bc\u8fd4\u56de\u5169\u500b\u6216\u591a\u500b\u67e5\u8a62\u7d50\u679c\u96c6\u7684\u4ea4\u96c6\u3002\u63db\u53e5\u8a71\u8aaa\uff0c\u53ea\u6709\u5728\u6240\u6709\u67e5\u8a62\u4e2d\u90fd\u5b58\u5728\u7684\u884c\u624d\u6703\u88ab\u8fd4\u56de\u3002\u9019\u5728\u9700\u8981\u5f9e\u591a\u500b\u8868\u4e2d\u63d0\u53d6\u5171\u540c\u6578\u64da\u6642\u975e\u5e38\u6709\u7528\u3002<\/p>\n<h2 id=\"oceanbase-%e4%b8%ad%e7%9a%84-intersect-%e8%aa%9e%e6%b3%95-aaXVLblUzL\">OceanBase \u4e2d\u7684 INTERSECT \u8a9e\u6cd5<\/h2>\n<p>\u5728 OceanBase \u4e2d\uff0cINTERSECT \u7684\u57fa\u672c\u8a9e\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre><code>SELECT column1, column2, ...\nFROM table1\nINTERSECT\nSELECT column1, column2, ...\nFROM table2;<\/code><\/pre>\n<p>\u9019\u6bb5 SQL \u8a9e\u53e5\u5c07\u8fd4\u56de\u5728 table1 \u548c table2 \u4e2d\u90fd\u5b58\u5728\u7684 column1 \u548c column2 \u7684\u503c\u3002<\/p>\n<h2 id=\"%e4%bd%bf%e7%94%a8%e7%af%84%e4%be%8b-aaXVLblUzL\">\u4f7f\u7528\u7bc4\u4f8b<\/h2>\n<p>\u5047\u8a2d\u6211\u5011\u6709\u5169\u500b\u8868\uff1a<code>employees<\/code> \u548c <code>contractors<\/code>\uff0c\u5b83\u5011\u7684\u7d50\u69cb\u5982\u4e0b\uff1a<\/p>\n<ul>\n<li><code>employees<\/code> \u8868\uff1a\u5305\u542b\u54e1\u5de5\u7684 ID \u548c\u59d3\u540d\u3002<\/li>\n<li><code>contractors<\/code> \u8868\uff1a\u5305\u542b\u627f\u5305\u5546\u7684 ID \u548c\u59d3\u540d\u3002<\/li>\n<\/ul>\n<p>\u6211\u5011\u5e0c\u671b\u627e\u51fa\u540c\u6642\u5728 <code>employees<\/code> \u548c <code>contractors<\/code> \u8868\u4e2d\u51fa\u73fe\u7684\u59d3\u540d\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b SQL \u67e5\u8a62\uff1a<\/p>\n<pre><code>SELECT name\nFROM employees\nINTERSECT\nSELECT name\nFROM contractors;<\/code><\/pre>\n<p>\u9019\u5c07\u8fd4\u56de\u6240\u6709\u540c\u6642\u5728\u5169\u500b\u8868\u4e2d\u5b58\u5728\u7684\u59d3\u540d\u3002<\/p>\n<h2 id=\"intersect-%e7%9a%84%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a0%85-aaXVLblUzL\">INTERSECT \u7684\u6ce8\u610f\u4e8b\u9805<\/h2>\n<p>\u5728\u4f7f\u7528 INTERSECT \u6642\uff0c\u6709\u5e7e\u500b\u6ce8\u610f\u4e8b\u9805\u9700\u8981\u8003\u616e\uff1a<\/p>\n<ul>\n<li>\u6240\u6709\u67e5\u8a62\u7684\u5217\u6578\u548c\u6578\u64da\u985e\u578b\u5fc5\u9808\u76f8\u540c\u3002<\/li>\n<li>INTERSECT \u64cd\u4f5c\u6703\u81ea\u52d5\u53bb\u9664\u91cd\u8907\u7684\u884c\uff0c\u8fd4\u56de\u7684\u7d50\u679c\u96c6\u662f\u552f\u4e00\u7684\u3002<\/li>\n<li>\u5728\u67d0\u4e9b\u60c5\u6cc1\u4e0b\uff0c\u4f7f\u7528 INTERSECT \u53ef\u80fd\u6703\u5f71\u97ff\u67e5\u8a62\u6027\u80fd\uff0c\u7279\u5225\u662f\u5728\u8655\u7406\u5927\u578b\u6578\u64da\u96c6\u6642\u3002<\/li>\n<\/ul>\n<h2 id=\"%e6%80%a7%e8%83%bd%e8%80%83%e9%87%8f-aaXVLblUzL\">\u6027\u80fd\u8003\u91cf<\/h2>\n<p>\u5728 OceanBase \u4e2d\uff0cINTERSECT \u64cd\u4f5c\u7684\u6027\u80fd\u53d6\u6c7a\u65bc\u591a\u500b\u56e0\u7d20\uff0c\u5305\u62ec\u6578\u64da\u7684\u5927\u5c0f\u3001\u7d22\u5f15\u7684\u4f7f\u7528\u60c5\u6cc1\u4ee5\u53ca\u67e5\u8a62\u7684\u8907\u96dc\u6027\u3002\u70ba\u4e86\u63d0\u9ad8\u6027\u80fd\uff0c\u5efa\u8b70\u5728\u67e5\u8a62\u4e2d\u4f7f\u7528\u9069\u7576\u7684\u7d22\u5f15\uff0c\u4e26\u8003\u616e\u5c07\u6578\u64da\u96c6\u9650\u5236\u5728\u8f03\u5c0f\u7684\u7bc4\u570d\u5167\u3002<\/p>\n<h2 id=\"%e7%b5%90%e8%ab%96-aaXVLblUzL\">\u7d50\u8ad6<\/h2>\n<p>INTERSECT \u662f OceanBase \u4e2d\u4e00\u500b\u5f37\u5927\u7684\u529f\u80fd\uff0c\u80fd\u5920\u5e6b\u52a9\u7528\u6236\u8f15\u9b06\u7372\u53d6\u591a\u500b\u67e5\u8a62\u7d50\u679c\u7684\u4ea4\u96c6\u3002\u901a\u904e\u6b63\u78ba\u4f7f\u7528 INTERSECT\uff0c\u958b\u767c\u8005\u53ef\u4ee5\u66f4\u9ad8\u6548\u5730\u8655\u7406\u6578\u64da\uff0c\u4e26\u5f9e\u4e2d\u63d0\u53d6\u6709\u50f9\u503c\u7684\u4fe1\u606f\u3002\u5c0d\u65bc\u9700\u8981\u9ad8\u6027\u80fd\u548c\u9ad8\u53ef\u7528\u6027\u7684\u6578\u64da\u5eab\u89e3\u6c7a\u65b9\u6848\uff0cOceanBase \u7121\u7591\u662f\u4e00\u500b\u503c\u5f97\u8003\u616e\u7684\u9078\u64c7\u3002<\/p>\n<p>\u5982\u679c\u60a8\u5c0d\u65bc <a href=\"https:\/\/server.hk\">\u9999\u6e2f VPS<\/a> \u670d\u52d9\u6216\u5176\u4ed6\u76f8\u95dc\u6280\u8853\u6709\u8208\u8da3\uff0c\u6b61\u8fce\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u4ee5\u7372\u53d6\u66f4\u591a\u8cc7\u8a0a\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to use the INTERSECT operator in OceanBase with our comprehensive tutorial, enhancing your SQL query skills for efficient data retrieval.<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-160145","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/160145","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=160145"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/160145\/revisions"}],"predecessor-version":[{"id":160146,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/160145\/revisions\/160146"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=160145"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=160145"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=160145"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}