{"id":200869,"date":"2025-05-06T14:25:55","date_gmt":"2025-05-06T06:25:55","guid":{"rendered":"https:\/\/server.hk\/cnblog\/200869\/"},"modified":"2025-05-06T14:25:55","modified_gmt":"2025-05-06T06:25:55","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-exists-%e5%85%b3%e9%94%ae%e5%ad%97%e6%a3%80%e6%9f%a5%e4%b8%a4%e4%b8%aa%e8%a1%a8%e4%b8%ad%e6%98%af%e5%90%a6%e5%ad%98%e5%9c%a8%e5%af%b9%e5%ba%94%e5%80%bc%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/200869\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 EXISTS \u5173\u952e\u5b57\u68c0\u67e5\u4e24\u4e2a\u8868\u4e2d\u662f\u5426\u5b58\u5728\u5bf9\u5e94\u503c\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u5982\u4f55\u4f7f\u7528 EXISTS \u5173\u952e\u5b57\u68c0\u67e5\u4e24\u4e2a\u8868\u4e2d\u662f\u5426\u5b58\u5728\u5bf9\u5e94\u503c\uff1f<\/h1>\n<p>\u4e00\u5206\u8015\u8018\uff0c\u4e00\u5206\u6536\u83b7\uff01\u65e2\u7136\u6253\u5f00\u4e86\u8fd9\u7bc7\u6587\u7ae0\uff0c\u5c31\u575a\u6301\u770b\u4e0b\u53bb\u5427\uff01\u6587\u4e2d\u5185\u5bb9\u5305\u542b\u7b49\u7b49\u77e5\u8bc6\u70b9&#8230;\u5e0c\u671b\u4f60\u80fd\u5728\u9605\u8bfb\u672c\u6587\u540e\uff0c\u80fd\u771f\u771f\u5b9e\u5b9e\u5b66\u5230\u77e5\u8bc6\u6216\u8005\u5e2e\u4f60\u89e3\u51b3\u5fc3\u4e2d\u7684\u7591\u60d1\uff0c\u4e5f\u6b22\u8fce\u5927\u4f6c\u6216\u8005\u65b0\u4eba\u670b\u53cb\u4eec\u591a\u7559\u8a00\u8bc4\u8bba\uff0c\u591a\u7ed9\u5efa\u8bae\uff01\u8c22\u8c22\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241118\/1731909288673ad6a8f13a0.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528 exists \u5173\u952e\u5b57\u68c0\u67e5\u4e24\u4e2a\u8868\u4e2d\u662f\u5426\u5b58\u5728\u5bf9\u5e94\u7684\u503c\uff1f<\/strong><\/p>\n<p>\u5728 mysql \u4e2d\uff0cexists \u5173\u952e\u5b57\u53ef\u7528\u4e8e\u68c0\u67e5\u4e24\u4e2a\u8868\u4e2d\u662f\u5426\u5b58\u5728\u5bf9\u5e94\u7684\u503c\u3002\u8981\u4f7f\u7528 exists \u5173\u952e\u5b57\u68c0\u67e5\u4e3b\u8868(\u7b2c\u4e00\u5f20\u8868)\u4e2d\u662f\u5426\u5b58\u5728\u5b50\u8868(\u7b2c\u4e8c\u5f20\u8868)\u4e2d\u7684\u5185\u5bb9\uff0c\u8bf7\u6309\u7167\u4ee5\u4e0b\u6b65\u9aa4\u64cd\u4f5c\uff1a<\/p>\n<ol>\n<li>\u5c06\u5b50\u67e5\u8be2(\u7b2c\u4e8c\u5f20\u8868)\u4f5c\u4e3a exists \u5b50\u53e5\u7684\u53c2\u6570\u3002\u5b50\u67e5\u8be2\u5e94\u8fd4\u56de true \u6216 false\uff0c\u5177\u4f53\u53d6\u51b3\u4e8e\u5b50\u8868\u4e2d\u662f\u5426\u5b58\u5728\u4e0e\u4e3b\u8868\u5339\u914d\u7684\u503c\u3002<\/li>\n<li>\u5728\u4e3b\u67e5\u8be2\u4e2d\uff0c\u4f7f\u7528 exists \u5b50\u53e5\u68c0\u67e5\u5b50\u67e5\u8be2\u662f\u5426\u8fd4\u56de true\u3002\u5982\u679c\u5b50\u67e5\u8be2\u8fd4\u56de true\uff0c\u5219 exists \u6761\u4ef6\u4e3a true\uff0c\u8868\u660e\u5728\u4e3b\u8868\u4e2d\u627e\u5230\u4e86\u5339\u914d\u7684\u503c\u3002<\/li>\n<\/ol>\n<p>\u4ee5\u4e0b\u662f\u60a8\u63d0\u4f9b\u7684\u67e5\u8be2\u7684\u66f4\u6b63\u7248\u672c\uff1a<\/p>\n<pre>select * from (\n    select pn_Code, serialNumber from pnassertbasic_ruku pr left join pnassertruku pu on pr.parent_pnAssertRuku_id = pu.child_pnAssertRukuDetails_id\nwhere pn_Code is not null and serialNumber is not null and DATE(pr.create_time) = CURDATE() and pr.warehouseEntryNumber &amp;lt;&amp;gt; 'WEd3791f0b'\n) as temp1\nwhere EXISTS (\n    select * from (\n    select pn_Code, serialNumber from pnassertbasic_ruku pr left join pnassertruku pu on pr.parent_pnAssertRuku_id = pu.child_pnAssertRukuDetails_id\nwhere pu.child_pnAssertRukuDetails_id is null and pr.warehouseEntryNumber = 'WEd3791f0b'\n    ) as temp2\n    where temp1.pn_Code = temp2.pn_Code and temp1.serialNumber = temp2.serialNumber\n)<\/pre>\n<p>\u8bf7\u6ce8\u610f\uff0c\u6211\u4fee\u6539\u4e86 exists \u5b50\u53e5\u7684\u5b50\u67e5\u8be2\uff0c\u4ee5\u4fbf\u68c0\u67e5\u4e3b\u8868\u548c\u5b50\u8868\u7684 pn_code \u548c serialnumber \u5339\u914d\u3002<\/p>\n<p>\u5230\u8fd9\u91cc\uff0c\u6211\u4eec\u4e5f\u5c31\u8bb2\u5b8c\u4e86\u300a\u5982\u4f55\u4f7f\u7528 EXISTS \u5173\u952e\u5b57\u68c0\u67e5\u4e24\u4e2a\u8868\u4e2d\u662f\u5426\u5b58\u5728\u5bf9\u5e94\u503c\uff1f\u300b\u7684\u5185\u5bb9\u4e86\u3002\u4e2a\u4eba\u8ba4\u4e3a\uff0c\u57fa\u7840\u77e5\u8bc6\u7684\u5b66\u4e60\u548c\u5de9\u56fa\uff0c\u662f\u4e3a\u4e86\u66f4\u597d\u7684\u5c06\u5176\u8fd0\u7528\u5230\u9879\u76ee\u4e2d\uff0c\u6b22\u8fce\u5173\u6ce8\u4e3b\u673a\u5b9d\u8d1d\u516c\u4f17\u53f7\uff0c\u5e26\u4f60\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u7684\u77e5\u8bc6\u70b9\uff01<\/p>\n<dl>\n<dt>\n <\/dt>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u4f7f\u7528 EXISTS \u5173\u952e\u5b57\u68c0&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-200869","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200869","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"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=200869"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200869\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=200869"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=200869"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=200869"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}