{"id":26575,"date":"2024-11-24T15:31:15","date_gmt":"2024-11-24T07:31:15","guid":{"rendered":"https:\/\/fwq.ai\/blog\/26575\/"},"modified":"2024-11-24T15:31:15","modified_gmt":"2024-11-24T07:31:15","slug":"%e5%a6%82%e4%bd%95%e6%9f%a5%e6%89%be-mysql-%e4%b8%ad%e8%b6%85%e8%bf%87%e6%8c%87%e5%ae%9a%e6%97%b6%e6%ae%b5%e6%9c%aa%e6%b4%bb%e8%b7%83%e7%9a%84%e8%ae%b0%e5%bd%95%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/26575\/","title":{"rendered":"\u5982\u4f55\u67e5\u627e MySQL \u4e2d\u8d85\u8fc7\u6307\u5b9a\u65f6\u6bb5\u672a\u6d3b\u8dc3\u7684\u8bb0\u5f55\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173098944419438.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u67e5\u627e MySQL \u4e2d\u8d85\u8fc7\u6307\u5b9a\u65f6\u6bb5\u672a\u6d3b\u8dc3\u7684\u8bb0\u5f55\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u67e5\u627e MySQL \u4e2d\u8d85\u8fc7\u6307\u5b9a\u65f6\u6bb5\u672a\u6d3b\u8dc3\u7684\u8bb0\u5f55\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u67e5\u8be2  \u4e2d\u8d85\u8fc7\u6307\u5b9a\u65f6\u6bb5\u672a\u6d3b\u8dc3\u7684\u8bb0\u5f55\uff1f<\/strong><\/p>\n<p>\u5bf9\u4e8e\u521d\u5b66\u8005\u6765\u8bf4\uff0c\u5982\u4f55\u7f16\u5199 sql \u8bed\u53e5\u6765\u67e5\u8be2\u4e00\u6bb5\u65f6\u95f4\u5185\u672a\u6267\u884c\u7279\u5b9a\u64cd\u4f5c\u7684\u7279\u5b9a\u8bb0\u5f55\u53ef\u80fd\u662f\u5177\u6709\u6311\u6218\u6027\u7684\u3002\u4e0b\u9762\u63d0\u4f9b\u4e00\u79cd mysql \u67e5\u8be2\uff0c\u53ef\u5e2e\u52a9\u4f60\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002<\/p>\n<p><strong>\u67e5\u8be2\u8bed\u53e5\uff1a<\/strong><\/p>\n<pre>select * from admin where id not in (select distinct admin_id from admin_log where  created_at &gt; date_sub(now(),interval 2 month)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u67e5\u8be2\u8bf4\u660e\uff1a<\/strong><\/p>\n<ul>\n<li> <strong>select * from admin:<\/strong> \u9009\u62e9 &#8220;admin&#8221; \u8868\u4e2d\u7684\u6240\u6709\u5217\u3002<\/li>\n<li> <strong>where id not in ( &#8230; ):<\/strong> \u6392\u9664\u7b26\u5408\u5b50\u67e5\u8be2\u4e2d\u6761\u4ef6\u7684\u8bb0\u5f55\u3002<\/li>\n<li> <strong>select distinct admin_id from admin_log:<\/strong> \u4ece &#8220;admin_log&#8221; \u8868\u4e2d\u9009\u62e9\u4e0d\u540c\u7684 &#8220;admin_id&#8221;\u3002<\/li>\n<li> <strong>where created_at &gt; date_sub(now(),interval 2 month):<\/strong> \u5728\u8fc7\u53bb\u4e24\u4e2a\u6708\u5185\u5177\u6709 &#8220;created_at&#8221; \u503c\u7684\u8bb0\u5f55\u3002<\/li>\n<\/ul>\n<p>\u6b64\u67e5\u8be2\u5c06\u4ece &#8220;admin&#8221; \u8868\u4e2d\u9009\u62e9\u6240\u6709\u4e0d\u5c5e\u4e8e\u5728\u8fc7\u53bb\u4e24\u4e2a\u6708\u5185\u8bb0\u5f55\u4e86\u64cd\u4f5c\u7684 &#8220;admin_id&#8221; \u7684\u8bb0\u5f55\u3002\u6839\u636e\u4f60\u7684\u793a\u4f8b\uff0c\u8fd9\u610f\u5473\u7740\u5b83\u5c06\u9009\u62e9\u540d\u4e3a &#8220;\u5c0f\u660e&#8221; \u7684\u7ba1\u7406\u5458\uff0c\u4ed6\u4eec\u6700\u8fd1\u4e24\u4e2a\u6708\u6ca1\u6709\u6267\u884c\u4efb\u4f55\u64cd\u4f5c\u3002<\/p>\n<p>\u8bf7\u6ce8\u610f\uff0c\u6b64\u67e5\u8be2\u9700\u8981\u4e00\u4e2a\u540d\u4e3a &#8220;admin_log&#8221; \u7684\u8868\uff0c\u5176\u4e2d\u5b58\u50a8\u4e86\u7ba1\u7406\u5458\u7684\u64cd\u4f5c\u8bb0\u5f55\uff0c\u5305\u62ec &#8220;created_at&#8221; \u65f6\u95f4\u6233\u5217\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u67e5\u627e MySQL \u4e2d\u8d85\u8fc7\u6307\u5b9a\u65f6\u6bb5\u672a\u6d3b\u8dc3\u7684\u8bb0\u5f55\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u67e5\u8be2 \u4e2d\u8d85\u8fc7\u6307\u5b9a\u65f6\u6bb5\u672a\u6d3b\u8dc3\u7684\u8bb0\u5f55\uff1f \u5bf9\u4e8e\u521d\u5b66\u8005\u6765\u8bf4\uff0c\u5982\u4f55\u7f16\u5199 sql \u8bed\u53e5\u6765\u67e5\u8be2\u4e00\u6bb5\u65f6\u95f4\u5185\u672a\u6267\u884c\u7279\u5b9a\u64cd\u4f5c\u7684\u7279\u5b9a\u8bb0\u5f55\u53ef\u80fd\u662f\u5177\u6709\u6311\u6218\u6027\u7684\u3002\u4e0b\u9762\u63d0\u4f9b\u4e00\u79cd mysql \u67e5\u8be2\uff0c\u53ef\u5e2e\u52a9\u4f60\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\u3002 \u67e5\u8be2\u8bed\u53e5\uff1a select * from admin where id not in (select distinct admin_id from admin_log where created_at &gt; date_sub(now(),interval 2 month) \u767b\u5f55\u540e\u590d\u5236 \u67e5\u8be2\u8bf4\u660e\uff1a select * from admin: \u9009\u62e9 &#8220;admin&#8221; \u8868\u4e2d\u7684\u6240\u6709\u5217\u3002 where id not in ( &#8230; ): \u6392\u9664\u7b26\u5408\u5b50\u67e5\u8be2\u4e2d\u6761\u4ef6\u7684\u8bb0\u5f55\u3002 select distinct admin_id from admin_log: \u4ece &#8220;admin_log&#8221; \u8868\u4e2d\u9009\u62e9\u4e0d\u540c\u7684 &#8220;admin_id&#8221;\u3002 where created_at [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-26575","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26575","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=26575"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/26575\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=26575"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=26575"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=26575"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}