{"id":4023,"date":"2023-11-03T09:35:05","date_gmt":"2023-11-03T01:35:05","guid":{"rendered":"https:\/\/white-night.club\/?p=4023"},"modified":"2023-11-09T11:07:43","modified_gmt":"2023-11-09T03:07:43","slug":"db14","status":"publish","type":"post","link":"https:\/\/white-night.club\/index.php\/2023\/11\/03\/db14\/","title":{"rendered":"MySQL\uff1a\u81f3\u5c11\u53c2\u4e0exxx\u53c2\u4e0e\u7684\u5168\u90e8\u4e8b\u4ef6\uff08\u4e8c\uff09"},"content":{"rendered":"\n<p>\u672c\u6765\u4e0d\u96be\u7684\uff0c\u7ed3\u679c\u5b9e\u9a8c\u8bfe\u4e0a\u53c8\u6ca1\u80fd\u5f53\u573a\u505a\u51fa\u6765\u3002\u8fd8\u662f\u56de\u5230\u5bbf\u820d\u590d\u76d8\u624d\u770b\u5230\u95ee\u9898\u6240\u5728\uff0c\u4ee4\u4eba\u611f\u6168\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>\u5934\u6b4c\u4f8b\u9898<\/p>\n<cite><em>\u4ed4\u7ec6\u5ba1\u9898<\/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>\u521b\u5efa\u4e00\u4e2a\u540d\u4e3atest\u7684\u89c6\u56fe\uff0c\u67e5\u8be2\u8fd9\u6837\u7684\u9009\u624b\u4fe1\u606f(users\u8868)\uff0c<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">\u53c2\u52a0\u8fc7\u4e09\u6b21\u6bd4\u8d5b(\u4e0d\u5305\u542bnull)<\/mark>\uff0c\u4e14\u81f3\u5c11\u89e3\u7b54\u8fc7&#8221;202002020217&#8243;\u9009\u624bresult\u4e3a4\u4e14\u91c7\u7528language\u4e3a1\u89e3\u7b54\u8fc7\u7684<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">\u6240\u6709\u9898\u76ee<\/mark>\u3002<\/p>\n\n\n\n<p><strong>\u63d0\u793a\uff1a<\/strong>count(distinct \u5217\u540d)\uff1a\u6839\u636e\u6307\u5b9a\u7684\u5217\u7edf\u8ba1\u8bb0\u5f55\u603b\u6570\uff0c\u53bb\u91cd\u590d\u4e14\u4e0d\u5305\u62ecNULL\u503c\u3002<\/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 aligncenter is-resized has-custom-border\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/data.educoder.net\/api\/attachments\/2132713\" alt=\",\" style=\"border-style:none;border-width:0px;border-radius:0px\" width=\"839\" height=\"227\"\/><\/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 loading=\"lazy\" decoding=\"async\" src=\"https:\/\/data.educoder.net\/api\/attachments\/2132719\" alt=\",\" style=\"border-style:none;border-width:0px;border-radius:0px\" width=\"494\" height=\"202\"\/><\/figure>\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>\u89e3\u9898\u601d\u8def<\/p>\n<cite><em>\u770b\u9898<\/em><\/cite><\/blockquote>\n\n\n\n<p>\u6211\u5f53\u65f6\u770b\u5230\u8fd9\u9898\uff0c\u563f\uff0c\u53c8\u662f\u5d4c\u5957NOT EXISTS\uff0c\u8fd9\u4e2a\u6211\u719f\u554a\uff0c\u4e24\u5206\u949f\u7ed9\u4f60\u5199\u5b8c\u3002\u89c6\u56fe\u76f4\u63a5AS\u5c31\u884c\u4e86\uff0c\u6ca1\u5565\u5f71\u54cd\u3002\u7136\u540e\u8fd9\u662f\u6211\u5f53\u65f6\u5199\u7684SQL<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE VIEW test \nAS \nSELECT A.user_id,A.reg_time,A.name \nFROM users AS A\nJOIN solution AS B\nON A.user_id=B.user_id\nWHERE NOT EXISTS(\n    SELECT 1 \n    FROM solution AS C \n    WHERE C.user_id='202002020217' AND C.result=4 AND C.language=1 \n    AND NOT EXISTS( \n        SELECT 1 \n        FROM solution AS D \n        WHERE A.user_id=D.user_id AND <mark style=\"background-color:rgba(0, 0, 0, 0);color:#ffdf00\" class=\"has-inline-color\">C.contest_id=D.contest_id<\/mark> ) \n)\nGROUP BY A.user_id\nHAVING COUNT(DISTINCT B.contest_id)=3;<\/code><\/pre>\n\n\n\n<p>\u7136\u540e\u70b9\u4e86\u4e0b\u63d0\u4ea4\uff0c\u55ef\uff1f\u5c45\u7136\u6ca1\u8fc7\uff0c\u8fd9\u662f\u600e\u4e48\u56de\u4e8b\u5462\uff1f\u7136\u540e\u5f00\u59cb\u68c0\u67e5\u3002<\/p>\n\n\n\n<p>\u53c2\u4e0e\u4e863\u573a\u6bd4\u8d5b\u548c\u53c2\u4e0e\u4e86xxx\u53c2\u4e0e\u7684\u5168\u90e8\u6bd4\u8d5b\u662f<mark style=\"background-color:rgba(0, 0, 0, 0);color:#fcb900\" class=\"has-inline-color\">\u5e76\u5217<\/mark>\u5173\u7cfb\uff1b\u53c2\u4e0e\u4e86xxx\u53c2\u4e0e\u7684\u6bd4\u8d5b\u76f8\u6bd4\u4e8e\u4e0a\u6b21\u65b0\u589e\u4e86\u51e0\u4e2a\u9650\u5236\u6761\u4ef6\u3002<\/p>\n\n\n\n<p>\u90a3\u601d\u8def\u5c31\u662f\uff1a<\/p>\n\n\n\n<ul>\n<li>\u5148\u7b5b\u9009\u51faxxx\u53c2\u4e0e\u7684\u6240\u6709\u6bd4\u8d5b\uff08\u52a0\u4e0a\u51e0\u4e2a\u9650\u5236\u6761\u4ef6\uff09\u5f97\u5230\u7ed3\u679c\u96c6A\uff1b<\/li>\n\n\n\n<li>\u518d\u4eceA\u4e2d\u9009\u51fa\u53c2\u4e0e\u4e86\u67d0\u4e2a\u53c2\u4e0e\u7684\u7ed3\u679c\u96c6A\u4e2d\u6240\u6709\u6bd4\u8d5b\u7684\u9009\u624b\uff0c\u5f97\u5230\u7ed3\u679c\u96c6B\uff1b<\/li>\n\n\n\n<li>\u6700\u540e\u518d\u5bf9B\u8fdb\u884c\u7b5b\u9009\u51fa\u53c2\u4e0e\u4e86\u4e09\u6b21\u6bd4\u8d5b\u7684\u9009\u624b\u5f97\u5230\u7ed3\u679c\u96c6C\u3002\u518d\u5bf9C\u8fdb\u884cSELECT\u5373\u53ef\u3002<\/li>\n<\/ul>\n\n\n\n<p>\u4e5f\u6ca1\u5176\u5b83\u7684\u4e86\uff0c\u4f46\u662f\u5c31\u662f\u8fc7\u4e0d\u4e86\uff0c\u4ffa\u5bfb\u601d\u8fd9\u4e5f\u6ca1\u9519\u554a\uff0c\u600e\u4e48\u56de\u4e8b\u5462\uff1f<\/p>\n\n\n\n<p>\u7136\u540e\u8fd9\u91cc\u8c03\u90a3\u91cc\u6539\uff0c\u8fd8\u662f\u6ca1\u8fc7\u3002\u8d8a\u8c03\u8d8a\u6025\u3002\u6700\u540e\u56de\u5230\u5bbf\u820d\u4ed4\u7ec6\u590d\u76d8\u7684\u65f6\u5019\u53d1\u73b0\uff0c\u9898\u76ee\u8981\u7684\u662fproblem_id\uff0c\u8981\u7684\u662fxxx\u53c2\u4e0e\u8fc7\u7684\u6240\u6709\u9898\u76ee\uff0c\u800c\u4e0d\u662f\u6240\u6709\u6bd4\u8d5b&#8230;\u90a3\u6539\u4e00\u4e0b\u7b5b\u9009\u7ed3\u679c\u96c6B\u7684\u6761\u4ef6\u4e0d\u5c31\u5b8c\u4e8b\u4e86&#8230;.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>CREATE VIEW test \nAS \nSELECT A.user_id,A.reg_time,A.name \nFROM users AS A\nJOIN solution AS B\nON A.user_id=B.user_id\nWHERE NOT EXISTS(\n    SELECT 1 \n    FROM solution AS C \n    WHERE C.user_id='202002020217' AND C.result=4 AND C.language=1 \n    AND NOT EXISTS( \n        SELECT 1 \n        FROM solution AS D \n        WHERE A.user_id=D.user_id AND C.problem_id=D.problem_id ) \n)\nGROUP BY A.user_id\nHAVING COUNT(DISTINCT B.contest_id)=3;<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u66f4\u591a\u9650\u5236\u6761\u4ef6\u7684\u5d4c\u5957NOT EXISTS<\/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],"_links":{"self":[{"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/4023"}],"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=4023"}],"version-history":[{"count":0,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/posts\/4023\/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=4023"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/categories?post=4023"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/white-night.club\/index.php\/wp-json\/wp\/v2\/tags?post=4023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}