{"id":3539,"date":"2023-10-26T22:31:35","date_gmt":"2023-10-26T14:31:35","guid":{"rendered":"https:\/\/white-night.club\/?p=3539"},"modified":"2024-02-28T14:46:34","modified_gmt":"2024-02-28T06:46:34","slug":"db13","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/10\/26\/db13\/","title":{"rendered":"MySQL\uff1a\u81f3\u5c11\u53c2\u4e0exxx\u53c2\u4e0e\u7684\u5168\u90e8\u4e8b\u4ef6"},"content":{"rendered":"\n<p>\u8fd9\u73a9\u610f\uff0c\u671f\u672b\u8981\u8003\uff0c\u8fd8\u662f\u91cd\u70b9\u3002\u6240\u4ee5\u4e0d\u5f97\u4e0d\u4ed4\u7ec6\u601d\u8003\u601d\u8003\u600e\u4e48\u5199\u4e86\u3002<\/p>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u4ec0\u4e48\u65f6\u5019\u7528NOT EXISTS<\/p>\n<cite><em>\u53cc\u91cd\u5426\u5b9a\u8868\u80af\u5b9a<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u4e4b\u524d\u867d\u7136\u5df2\u7ecf\u8bb2\u8fc7\u4e86\uff0c\u4e0d\u8fc7\u90a3\u4e00\u7bc7\u6587\u7ae0\u8bb2\u7684\u662f<a href=\"https:\/\/white-night.club\/index.php\/2023\/10\/12\/db5\/\" data-type=\"URL\" data-id=\"https:\/\/white-night.club\/index.php\/2023\/10\/12\/db5\/\" target=\"_blank\" rel=\"noreferrer noopener\"><mark style=\"background-color:rgba(0, 0, 0, 0);color:#0086ff\" class=\"has-inline-color\">\u53c2\u4e0e\u4e86\u5168\u90e8\u4e8b\u4ef6\u7684xxx<\/mark><\/a>\uff0c\u800c\u672c\u6587\u76f8\u6bd4\u4e8e\u90a3\u7bc7\u6587\u7ae0\u8fd8\u591a\u4e86\u4e00\u4e2a\u9650\u5236\u6761\u4ef6\uff1a\u53c2\u4e0e\u7684\u662f<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">xxx\u53c2\u4e0e\u7684\u5168\u90e8\u4e8b\u4ef6<\/mark>\u3002<\/p>\n\n\n\n<p>\u7b49\u4f1a\u6211\u4eec\u4f1a\u7528\u5177\u4f53\u4f8b\u5b50\u6765\u89e3\u91ca\u4ec0\u4e48\u53eb\u201c\u53c2\u4e0e\u4e86xxx\u53c2\u4e0e\u7684\u5168\u90e8\u4e8b\u4ef6\u201d\uff0c\u73b0\u5728\u5148\u6765\u56de\u987e\u4e00\u4e0b\u4ec0\u4e48\u65f6\u5019\u8981\u7528\u5d4c\u5957NOT EXISTS\u67e5\u8be2\u3002<\/p>\n\n\n\n<p>\u5047\u8bbe\u6211\u8981\u627e\u51fa\u8d2d\u4e70\u4e86\u5168\u90e8\u5546\u54c1\u7684\u987e\u5ba2\uff0c\u80fd\u7528EXISTS\u5417\uff1f\u4e0d\u884c\u3002\u56e0\u4e3aEXISTS\u53ea\u8981\u78b0\u5230\u4efb\u610f\u4e00\u6761\u5339\u914d\u7684\u8bb0\u5f55\u5c31\u4f1a\u9000\u51fa\u5faa\u73af\uff0c\u5e76\u8fd4\u56detrue\u3002<\/p>\n\n\n\n<p>\u90a3\u6211\u4eec\u53ea\u80fd\u7528NOT EXISTS\u53bb\u67e5\u8be2\u201c\u6ca1\u6709\u8d2d\u4e70\u5168\u90e8\u5546\u54c1\u7684\u7528\u6237\u201d\uff0c\u518d\u5728\u6700\u5916\u5c42\u5957\u5c42NOT EXISTS\uff0c\u8868\u793a\u201c\u67e5\u8be2\u4e0d\u5b58\u5728\u6ca1\u6709\u8d2d\u4e70\u5168\u90e8\u5546\u54c1\u7684\u7528\u6237\u201d\uff0c\u539f\u7406\u603b\u7684\u6765\u8bf4\u5c31\u662f\uff1a<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">\u53cc\u91cd\u5426\u5b9a\u8868\u80af\u5b9a<\/mark>\u3002<\/p>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u5177\u4f53\u4f8b\u5b50<\/p>\n<cite><em>\u67e5\u8be2\u81f3\u5c11\u53c2\u4e0e\u4e86xxx\u53c2\u4e0e\u7684\u5168\u90e8\u4e8b\u4ef6\u7684\u5bf9\u8c61<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u9996\u5148\u7406\u89e3\u8fd9\u53e5\u8bdd\u662f\u5565\u610f\u601d\uff1a\u67e5\u8be2\u81f3\u5c11\u53c2\u4e0e\u4e86A\u53c2\u4e0e\u7684\u5168\u90e8\u4e8b\u4ef6\u7684\u5bf9\u8c61B\u3002<\/p>\n\n\n\n<p>\u201c\u81f3\u5c11\u201d\uff0c\u90a3\u4e48\u610f\u5473\u7740B\u9664\u4e86\u53c2\u4e0e\u4e86A\u53c2\u4e0e\u7684\u5168\u90e8\u4e8b\u4ef6\uff0c\u8fd8\u6709\u53ef\u80fd\u53c2\u4e0e\u4e86A\u6ca1\u6709\u53c2\u4e0e\u7684\u4e8b\u4ef6\u3002<\/p>\n\n\n\n<p>\u4f46\u8fd9\u90e8\u5206\u6211\u4eec\u5e76\u4e0d\u9700\u8981\u7ba1\uff0c\u6211\u4eec\u53ea\u9700\u8981<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">\u5148\u67e5\u8be2\u51faA\u53c2\u4e0e\u4e86\u54ea\u4e9b\u4e8b\u4ef6<\/mark>\uff0c\u5f97\u5230\u7ed3\u679c\u96c6firstset\uff1b<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">\u518d\u5bf9firstset\u67e5\u8be2B\u662f\u5426\u6709\u53c2\u4e0efirstset\u4e2d\u7684\u5168\u90e8\u4e8b\u4ef6<\/mark>\uff0c\u6700\u540e\u5373\u53ef\u5f97\u5230\u7ed3\u679c\u3002<\/p>\n\n\n\n<p>\u8fd9\u91cc\u4ee5\u5934\u6b4c\u7684\u4e24\u9053\u9898\u4e3a\u4f8b\u3002<\/p>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u7528 NOT EXISTS \u5b9e\u73b0\u67e5\u8be2\u81f3\u5c11\u53c2\u4e0e\u8fc7&#8221;202002020217&#8243;\u9009\u624b\u53c2\u4e0e\u8fc7\u7684\u6240\u6709\u6bd4\u8d5b\u7684\u9009\u624b\u4fe1\u606f<\/p>\n<cite><em>\u5148\u7b5b\u9009\uff0c\u518d\u67e5\u8be2<\/em><\/cite><\/blockquote>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u4efb\u52a1\u63cf\u8ff0\">\u4efb\u52a1\u63cf\u8ff0<\/h3>\n\n\n\n<p>\u7528 NOT EXISTS \u5b9e\u73b0\u67e5\u8be2\u81f3\u5c11\u53c2\u4e0e\u8fc7&#8221;202002020217&#8243;\u9009\u624b\u53c2\u4e0e\u8fc7\u7684\u6240\u6709\u6bd4\u8d5b\u7684\u9009\u624b\u4fe1\u606f\uff0ccontest_id\u4e0d\u4e3aNULL<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u76f8\u5173\u77e5\u8bc6\">\u76f8\u5173\u77e5\u8bc6<\/h3>\n\n\n\n<p>1\u3001users\u4e3a\u9009\u624b\u4fe1\u606f\u8868\uff1b users\u8868\u5982\u4e0b\u56fe\uff08\u4ec5\u663e\u793a\u524d\u51e0\u6761\uff09\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter has-custom-border\"><img decoding=\"async\" src=\"https:\/\/data.educoder.net\/api\/attachments\/2132426\" alt=\",\" style=\"border-style:none;border-width:0px;border-radius:0px\"\/><\/figure>\n\n\n\n<p>\u73b0\u5df2\u6784\u5efausers\u8868\uff0c\u7ed3\u6784\u4fe1\u606f\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter has-custom-border\"><img decoding=\"async\" src=\"https:\/\/data.educoder.net\/api\/attachments\/2132429\" alt=\",\" style=\"border-style:none;border-width:0px;border-radius:0px\"\/><\/figure>\n\n\n\n<p>2\u3001solution\u4e3a\u9009\u624b\u63d0\u4ea4\u7684\u9898\u76ee\u89e3\u7b54 solution\u8868\u5982\u4e0b\u56fe\uff08\u4ec5\u663e\u793a\u524d\u51e0\u6761\uff09\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image has-custom-border\"><img decoding=\"async\" src=\"https:\/\/data.educoder.net\/api\/attachments\/2132713\" alt=\",\" style=\"border-style:none;border-width:0px;border-radius:0px\"\/><\/figure>\n\n\n\n<p>\u73b0\u5df2\u6784\u5efasolution\u8868\uff0c\u7ed3\u6784\u4fe1\u606f\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter is-resized has-custom-border\"><img decoding=\"async\" src=\"https:\/\/data.educoder.net\/api\/attachments\/2132719\" alt=\",\" style=\"border-style:none;border-width:0px;border-radius:0px;width:658px;height:269px\"\/><\/figure>\n\n\n\n<p>\u600e\u4e48\u5199\u5462\uff1f\u9996\u5148\u6211\u4eec\u8981\u5148\u7b5b\u9009\uff0c\u7b5b\u9009\u51faA\u53c2\u4e0e\u4e86\u54ea\u4e9b\u6bd4\u8d5b\uff0c\u518d\u5bf9\u5f97\u5230\u7684\u7ed3\u679c\u96c6\u8fdb\u884c\u4e8c\u6b21\u7b5b\u9009\u3002<\/p>\n\n\n\n<p>\u5355\u7eaf\u67e5\u8be2\u201cA\u53c2\u4e0e\u7684\u5168\u90e8\u6bd4\u8d5b\u201d\u5e76\u4e0d\u96be\u3002However\uff0c\u5728solution\u8868\u4e2d,<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">contest_id\u53ef\u80fd\u4e3a\u7a7a<\/mark>\uff0c\u8868\u793a\u201c\u8be5\u9898\u76ee\u4e0d\u5c5e\u4e8e\u4efb\u610f\u6bd4\u8d5b\u201c\u3002\u6240\u4ee5\u6211\u4eec\u8981\u4f5c\u4e2a\u975e\u7a7a\u5224\u65ad\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2b2b2b;color:#c7c7c7\">SQL<\/span><span role=\"button\" tabindex=\"0\" data-code=\"SELECT *\nFROM solution AS B\nWHERE B.user_id='202002020217' AND B.contest_id IS NOT NULL\n\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">SELECT<\/span><span style=\"color: #D4D4D4\"> *<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">FROM<\/span><span style=\"color: #D4D4D4\"> solution <\/span><span style=\"color: #569CD6\">AS<\/span><span style=\"color: #D4D4D4\"> B<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">WHERE<\/span><span style=\"color: #D4D4D4\"> B.user_id=<\/span><span style=\"color: #CE9178\">&#39;202002020217&#39;<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">AND<\/span><span style=\"color: #D4D4D4\"> B.contest_id <\/span><span style=\"color: #569CD6\">IS NOT NULL<\/span><\/span>\n<span class=\"line\"><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u6b64\u65f6\u6211\u4eec\u5f97\u5230\u4e86\u7b2c\u4e00\u4e2a\u7ed3\u679c\u96c6firstset\u3002\u8fd9\u4e2a\u7ed3\u679c\u96c6\u5305\u542b\u4e86\u6240\u6709A\u53c2\u4e0e\u7684\u6bd4\u8d5b\u3002\u90a3\u4e48\u63a5\u4e0b\u6765\u5c31\u662f\u8fdb\u884c\u4e8c\u6b21\u7b5b\u9009\uff0c\u627e\u51fa<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">\u54ea\u4e9b\u4eba\u53c2\u4e0e\u7684\u6bd4\u8d5b\u90fd\u80fd\u5728firstset\u4e2d\u627e\u5230\u8bb0\u5f55<\/mark>\u3002<\/p>\n\n\n\n<p>\u90a3\u4e48\u6700\u5185\u5c42\u7684NOT EXISTS\u5c31\u8868\u793a\uff1a<\/p>\n\n\n\n<ul>\n<li>\u5982\u679c\u6709\u4e2aB\u4eba\u5bf9\u4e8eA\u53c2\u4e0e\u7684\u4efb\u610f\u6bd4\u8d5b\u90fd\u6ca1\u6709\u53c2\u4e0e\uff0c\u90a3\u5b83\u80af\u5b9a\u4e0d\u662f\u6211\u4eec\u8981\u627e\u7684\u5bf9\u8c61\uff1b<\/li>\n\n\n\n<li>\u5982\u679c\u6709\u4e2aB\u4eba\u53ea\u53c2\u4e0e\u4e86\u90e8\u5206A\u53c2\u4e0e\u7684\u6bd4\u8d5b\uff0c\u867d\u7136\u80fd\u5339\u914d\u5230\u90e8\u5206\u6bd4\u8d5b\u7684\u8bb0\u5f55\uff0c\u4f46\u662f\u7531\u4e8e\u5185\u5c42\u5faa\u73af\u4f1a\u5339\u914d\u6bcf\u4e00\u6761\u8bb0\u5f55\uff0c\u5373\u5b83\u4f1a\u53bb\u5339\u914d\u6240\u6709A\u53c2\u4e0e\u8fc7\u7684\u6bd4\u8d5b\u3002\u90a3\u4e48<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">\u5bf9\u4e8e\u5269\u4e0bB\u6ca1\u53c2\u52a0\u7684\u6bd4\u8d5b<\/mark>\u800c\u8a00\u5b83\u4ecd\u7136\u627e\u4e0d\u5230\u5339\u914d\u7684\u8bb0\u5f55\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u4e0a\u9762\u8fd9\u4e24\u79cd\u60c5\u51b5\u90fd\u4f1a\u5bfc\u81f4\u5185\u5c42\u7684NOT EXISTS\u6700\u540e\u8fd4\u56detrue\u3002\u800ctrue\u5bf9\u4e0e\u6700\u5916\u5c42\u7684NOT EXISTS\u800c\u8a00\uff0c\u5c31\u76f8\u5f53\u4e8e\u5728\u544a\u8bc9\u5b83\uff1a<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">\u4e0d\u8981\u9009\u62e9\u8fd9\u4e9b\u6761\u4ef6\u4e3atrue\u7684\u8bb0\u5f55<\/mark>\u3002\u6240\u4ee5\u6700\u540e\u6211\u4eec\u624d\u80fd\u5f97\u5230\u201c\u53c2\u4e0e\u4e86A\u53c2\u4e0e\u7684\u5168\u90e8\u6bd4\u8d5b\u7684\u9009\u624b\u201d\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2b2b2b;color:#c7c7c7\">SQL<\/span><span role=\"button\" tabindex=\"0\" data-code=\"SELECT A.*\nFROM users AS A \nWHERE NOT EXISTS(\n    SELECT 1\n    FROM solution AS B\n    WHERE B.user_id='202002020217' AND B.contest_id IS NOT NULL\n    AND NOT EXISTS(\n        SELECT 1\n        FROM solution AS C\n        WHERE A.user_id=C.user_id AND B.contest_id=C.contest_id\n    )\n)\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">SELECT<\/span><span style=\"color: #D4D4D4\"> A.*<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">FROM<\/span><span style=\"color: #D4D4D4\"> users <\/span><span style=\"color: #569CD6\">AS<\/span><span style=\"color: #D4D4D4\"> A <\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">WHERE<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">NOT<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">EXISTS<\/span><span style=\"color: #D4D4D4\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">SELECT<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #B5CEA8\">1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">FROM<\/span><span style=\"color: #D4D4D4\"> solution <\/span><span style=\"color: #569CD6\">AS<\/span><span style=\"color: #D4D4D4\"> B<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">WHERE<\/span><span style=\"color: #D4D4D4\"> B.user_id=<\/span><span style=\"color: #CE9178\">&#39;202002020217&#39;<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">AND<\/span><span style=\"color: #D4D4D4\"> B.contest_id <\/span><span style=\"color: #569CD6\">IS NOT NULL<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">AND<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">NOT<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">EXISTS<\/span><span style=\"color: #D4D4D4\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #569CD6\">SELECT<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #B5CEA8\">1<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #569CD6\">FROM<\/span><span style=\"color: #D4D4D4\"> solution <\/span><span style=\"color: #569CD6\">AS<\/span><span style=\"color: #D4D4D4\"> C<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #569CD6\">WHERE<\/span><span style=\"color: #D4D4D4\"> A.user_id=C.user_id <\/span><span style=\"color: #569CD6\">AND<\/span><span style=\"color: #D4D4D4\"> B.contest_id=C.contest_id<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    )<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">)<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u603b\u7684\u6765\u8bf4\uff0c\u8fd9\u79cd\u9898\u7684\u91cd\u70b9<\/p>\n\n\n\n<ul>\n<li>\u5148\u5bf9\u54ea\u4e2a\u7ed3\u679c\u96c6\u8fdb\u884c\u7b5b\u9009\uff1f\uff08\u6761\u4ef6\u7b5b\u9009\uff09<\/li>\n\n\n\n<li>\u6700\u540e\u5f97\u5230\u7684\u7ed3\u679c\u96c6\u5e94\u7531\u54ea\u4e9b\u8bb0\u5f55\u7ec4\u6210\uff1f\uff08\u9010\u6761\u7b5b\u9009\uff09<\/li>\n\n\n\n<li><mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">\u6761\u4ef6\u6709\u6ca1\u6709\u53ef\u80fd\u4e3aNULL\uff1f<\/mark>\uff08\u56e0\u4e3aNOT EXISTS\u65e0\u6cd5\u5224\u65adNULL\uff0c\u5b83\u4f1a\u628a\u6240\u6709\u4e3aNULL\u7684\u8bb0\u5f55\u90fd\u5f53\u4f5c\u201c\u5b58\u5728\u201d\u5e76\u8fd4\u56detrue\uff09<\/li>\n<\/ul>\n\n\n\n<div style=\"height:60px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<blockquote class=\"wp-block-quote has-luminous-vivid-amber-color has-text-color\">\n<p>\u7b2c7\u5173\uff1a\u6c42\u81f3\u5c11\u7528\u4e86\u4f9b\u5e94\u5546 S1\u6240\u4f9b\u5e94\u7684\u5168\u90e8\u96f6\u4ef6\u7684\u5de5\u7a0b\u53f7 JNO<\/p>\n<cite><em>\u5148\u770b\u61c2\u9898<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u8fd9\u79cd\u9898\u8981\u662f\u80fd\u770b\u61c2\u9898\u76ee\uff0c\u518d\u5957\u4e24\u4e2aNOT EXISTS\u5c31\u5dee\u4e0d\u591a\u80fd\u5199\u51fa\u6765\u4e86\u3002\u95ee\u9898\u662f\u80fd\u4e0d\u80fd\u770b\u61c2\u9898\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u4efb\u52a1\u63cf\u8ff0\">\u4efb\u52a1\u63cf\u8ff0<\/h3>\n\n\n\n<p>\u6c42\u81f3\u5c11\u7528\u4e86\u4f9b\u5e94\u5546 S1\u6240\u4f9b\u5e94\u7684\u5168\u90e8\u96f6\u4ef6\u7684\u5de5\u7a0b\u53f7 JNO<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"\u76f8\u5173\u77e5\u8bc6\">\u76f8\u5173\u77e5\u8bc6<\/h3>\n\n\n\n<p>\u4f9b\u5e94\u60c5\u51b5\u8868SPJ\u7531\u4f9b\u5e94\u5546\u4ee3\u7801(SNO)\u3001\u96f6\u4ef6\u4ee3\u7801(PNO)\u3001\u5de5\u7a0b\u9879\u76ee\u4ee3\u7801(JNO)\u3001\u4f9b\u5e94\u6570\u91cf(QTY)\u7ec4\u6210\uff0c\u6807\u8bc6\u67d0\u4f9b\u5e94\u5546 \u4f9b\u5e94\u67d0\u79cd\u96f6\u4ef6 \u7ed9\u67d0\u5de5\u7a0b\u9879\u76ee\u7684\u6570\u91cf\u4e3aQTY\u3002 SPJ\u8868\u5982\u4e0b\u56fe\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter has-custom-border\"><img decoding=\"async\" src=\"https:\/\/data.educoder.net\/api\/attachments\/2131757\" alt=\",\" style=\"border-style:none;border-width:0px;border-radius:0px\"\/><\/figure>\n\n\n\n<p>\u73b0\u5df2\u6784\u5efaSPJ\u8868\uff0c\u7ed3\u6784\u4fe1\u606f\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter has-custom-border\"><img decoding=\"async\" src=\"https:\/\/data.educoder.net\/api\/attachments\/2131761\" alt=\",\" style=\"border-style:none;border-width:0px;border-radius:0px\"\/><\/figure>\n\n\n\n<p>\u6211\u53cd\u6b63\u662f\u7b2c\u4e00\u773c\u6ca1\u770b\u61c2\u3002\u4ec0\u4e48\u73a9\u610f\uff1f\u4ec0\u4e48\u53eb\u7528\u4e86\u4f9b\u5e94\u5546S1\u4f9b\u5e94\u7684\u5168\u90e8\u96f6\u4ef6\uff1f\u6211\u770b\u4e0d\u61c2\u554a\u3002<\/p>\n\n\n\n<p>\u518d\u4ed4\u7ec6\u770b\u770b\uff0cS1\u5c31\u4f9b\u5e94\u4e86\u4e24\u79cd\u96f6\u4ef6\uff0cP1\u548cP2\u3002\u7b80\u5355\u6765\u8bf4\uff0c\u8fd9\u4e48\u957f\u4e00\u53e5\u8bdd\u6d53\u7f29\u4e4b\u540e\u5c31\u662f\uff1a\u627e\u51fa\u7528\u8fc7P1\u548cP2\u7684\u5de5\u7a0b\u3002\u6211\u4e5f\u771f\u7684\u662f\u670d\u4e86\u51fa\u9898\u4eba\u4e86\uff0c\u8fd9\u53e5\u5b50\u90fd\u80fd\u7ed9\u4f60\u60f3\u5230\u3002<\/p>\n\n\n\n<p>\u90a3\u4e48\u8fd8\u662f\u8001\u6837\u5b50\uff0c\u5148\u6761\u4ef6\u7b5b\u9009\u518d\u9010\u6761\u7b5b\u9009\u3002\u6761\u4ef6\u662f\u4ec0\u4e48\uff1fS1\u751f\u4ea7\u7684\u96f6\u4ef6\u3002\u90a3\u4e48\u5148\u6761\u4ef6\u7b5b\u9009<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(1 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2b2b2b;color:#c7c7c7\">SQL<\/span><span role=\"button\" tabindex=\"0\" data-code=\"SELECT B.*\nFROM SPJ AS B \nWHERE SNO='S1'\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">SELECT<\/span><span style=\"color: #D4D4D4\"> B.*<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">FROM<\/span><span style=\"color: #D4D4D4\"> SPJ <\/span><span style=\"color: #569CD6\">AS<\/span><span style=\"color: #D4D4D4\"> B <\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">WHERE<\/span><span style=\"color: #D4D4D4\"> SNO=<\/span><span style=\"color: #CE9178\">&#39;S1&#39;<\/span><\/span><\/code><\/pre><\/div>\n\n\n\n<p>\u63a5\u4e0b\u6765\u5bf9\u4e0a\u9762\u5f97\u5230\u7684\u7ed3\u679c\u96c6firstset\u9010\u6761\u7b5b\u9009\uff0c\u4e5f\u5c31\u662f\u5957\u4e24\u4e2aNOT EXISTS\uff0c\u5b8c\u4e8b\u3002<\/p>\n\n\n\n<div class=\"wp-block-kevinbatdorf-code-block-pro cbp-has-line-numbers\" data-code-block-pro-font-family=\"Code-Pro-JetBrains-Mono\" style=\"font-size:.875rem;font-family:Code-Pro-JetBrains-Mono,ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,monospace;--cbp-line-number-color:#D4D4D4;--cbp-line-number-width:calc(2 * 0.6 * .875rem);line-height:1.25rem;--cbp-tab-width:2;tab-size:var(--cbp-tab-width, 2)\"><span style=\"display:flex;align-items:center;padding:10px 0px 10px 16px;margin-bottom:-2px;width:100%;text-align:left;background-color:#2b2b2b;color:#c7c7c7\">SQL<\/span><span role=\"button\" tabindex=\"0\" data-code=\"SELECT DISTINCT A.JNO\nFROM SPJ AS A \nWHERE NOT EXISTS(\n    SELECT B.*\n    FROM SPJ AS B \n    WHERE SNO='S1'\n    AND NOT EXISTS(\n        SELECT C.*\n        FROM SPJ AS C \n        WHERE B.PNO=C.PNO AND A.JNO=C.JNO\n    )\n)\" style=\"color:#D4D4D4;display:none\" aria-label=\"Copy\" class=\"code-block-pro-copy-button\"><svg xmlns=\"http:\/\/www.w3.org\/2000\/svg\" style=\"width:24px;height:24px\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\" stroke-width=\"2\"><path class=\"with-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2m-6 9l2 2 4-4\"><\/path><path class=\"without-check\" stroke-linecap=\"round\" stroke-linejoin=\"round\" d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"><\/path><\/svg><\/span><pre class=\"shiki dark-plus\" style=\"background-color: #1E1E1E\" tabindex=\"0\"><code><span class=\"line\"><span style=\"color: #569CD6\">SELECT DISTINCT<\/span><span style=\"color: #D4D4D4\"> A.JNO<\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">FROM<\/span><span style=\"color: #D4D4D4\"> SPJ <\/span><span style=\"color: #569CD6\">AS<\/span><span style=\"color: #D4D4D4\"> A <\/span><\/span>\n<span class=\"line\"><span style=\"color: #569CD6\">WHERE<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">NOT<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">EXISTS<\/span><span style=\"color: #D4D4D4\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">SELECT<\/span><span style=\"color: #D4D4D4\"> B.*<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">FROM<\/span><span style=\"color: #D4D4D4\"> SPJ <\/span><span style=\"color: #569CD6\">AS<\/span><span style=\"color: #D4D4D4\"> B <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">WHERE<\/span><span style=\"color: #D4D4D4\"> SNO=<\/span><span style=\"color: #CE9178\">&#39;S1&#39;<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    <\/span><span style=\"color: #569CD6\">AND<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">NOT<\/span><span style=\"color: #D4D4D4\"> <\/span><span style=\"color: #569CD6\">EXISTS<\/span><span style=\"color: #D4D4D4\">(<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #569CD6\">SELECT<\/span><span style=\"color: #D4D4D4\"> C.*<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #569CD6\">FROM<\/span><span style=\"color: #D4D4D4\"> SPJ <\/span><span style=\"color: #569CD6\">AS<\/span><span style=\"color: #D4D4D4\"> C <\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">        <\/span><span style=\"color: #569CD6\">WHERE<\/span><span style=\"color: #D4D4D4\"> B.PNO=C.PNO <\/span><span style=\"color: #569CD6\">AND<\/span><span style=\"color: #D4D4D4\"> A.JNO=C.JNO<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">    )<\/span><\/span>\n<span class=\"line\"><span style=\"color: #D4D4D4\">)<\/span><\/span><\/code><\/pre><\/div>\n","protected":false},"excerpt":{"rendered":"<p>NOT EXISTS\u5d4c\u5957\u67e5\u8be2\u8be6\u89e3<\/p>\n","protected":false},"author":1,"featured_media":3123,"comment_status":"open","ping_status":"","sticky":false,"template":"base","format":"standard","meta":{"footnotes":""},"categories":[69,35],"tags":[99,80],"_links":{"self":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/3539"}],"collection":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/comments?post=3539"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/3539\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media\/3123"}],"wp:attachment":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/media?parent=3539"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=3539"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=3539"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}