{"id":27001,"date":"2024-11-24T13:56:16","date_gmt":"2024-11-24T05:56:16","guid":{"rendered":"https:\/\/fwq.ai\/blog\/27001\/"},"modified":"2024-11-24T13:56:16","modified_gmt":"2024-11-24T05:56:16","slug":"mysql%e5%ad%90%e6%9f%a5%e8%af%a2%e6%9b%b4%e6%96%b0%e8%a1%a8%e6%97%b6%e4%b8%ba%e4%bd%95%e5%8a%a0%e4%b8%80%e5%b1%82%e5%8c%85%e8%a3%b9%e8%83%bd%e8%a7%a3%e5%86%b3%e6%8a%a5%e9%94%99%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/27001\/","title":{"rendered":"MySQL\u5b50\u67e5\u8be2\u66f4\u65b0\u8868\u65f6\u4e3a\u4f55\u52a0\u4e00\u5c42\u5305\u88f9\u80fd\u89e3\u51b3\u62a5\u9519\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173114551261766.jpg\" class=\"aligncenter\" title=\"MySQL\u5b50\u67e5\u8be2\u66f4\u65b0\u8868\u65f6\u4e3a\u4f55\u52a0\u4e00\u5c42\u5305\u88f9\u80fd\u89e3\u51b3\u62a5\u9519\uff1f\u63d2\u56fe\" alt=\"MySQL\u5b50\u67e5\u8be2\u66f4\u65b0\u8868\u65f6\u4e3a\u4f55\u52a0\u4e00\u5c42\u5305\u88f9\u80fd\u89e3\u51b3\u62a5\u9519\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>SQL\u5b50\u67e5\u8be2\u66f4\u65b0\u8868\u65f6\u52a0\u4e00\u5c42\u5305\u88f9\u4e3a\u4f55\u594f\u6548\uff1f<\/strong><\/p>\n<p>\u5728MySQL\u4e2d\uff0c\u66f4\u65b0\u8bed\u53e5\uff08\u5982DELETE\u3001INSERT\u3001UPDATE\uff09\u9700\u8981\u66f4\u65b0\u7684\u8868\u548c\u5b50\u67e5\u8be2\u4e2d\u7684FROM\u8868\u4e0d\u80fd\u76f8\u540c\u3002\u8fd9\u5bfc\u81f4\u4e86\u4ee5\u4e0bSQL\u8bed\u53e5\u62a5\u9519\uff1a&#8221;delete FROM sys_post WHERE post_id NOT IN (SELECT MIN(post_id) AS min_id FROM sys_post GROUP BY post_name);\u201d\u3002<\/p>\n<p>\u7136\u800c\uff0c\u901a\u8fc7\u7ed9\u5b50\u67e5\u8be2\u52a0\u4e00\u5c42\u62ec\u53f7\u5305\u88f9\uff0c\u95ee\u9898\u5f97\u4ee5\u89e3\u51b3\uff1a&#8221;delete FROM sys_post WHERE post_id NOT IN (SELECT t.min_id FROM (SELECT MIN(post_id) AS min_id FROM sys_post GROUP BY post_name) t);\u201d\u3002<\/p>\n<p>\u8fd9\u4e00\u8bbe\u8ba1\u7684\u7f18\u7531\u6765\u81eaMySQL\u81ea\u8eab\u7684\u673a\u5236\u9650\u5236\uff0c\u5176\u4ed6\u6570\u636e\u5e93\u6ca1\u6709\u8fd9\u6837\u7684\u7ea6\u675f\u3002\u6839\u636e\u5b98\u65b9\u6587\u6863\uff0c\u66f4\u65b0\u8bed\u53e5\u548c\u5b50\u67e5\u8be2FROM\u4e2d\u7684\u8868\u4e0d\u80fd\u6307\u5411\u540c\u4e00\u5f20\u8868\u3002<\/p>\n<p>\u4e3a\u4e86\u7ed5\u5f00\u8fd9\u4e00\u7ea6\u675f\uff0cMySQL\u63d0\u4f9b\u4e86\u4e00\u4e2a\u89e3\u51b3\u65b9\u6cd5\uff1a\u521b\u5efa\u4e00\u5f20\u4e2d\u95f4\u8868\uff08\u884d\u751f\u8868\uff09\u5e76\u4e3a\u5176\u6307\u5b9a\u4e00\u4e2a\u522b\u540d\uff0c\u7136\u540e\u5728\u5b50\u67e5\u8be2\u4e2d\u4f7f\u7528\u8be5\u522b\u540d\u3002<\/p>\n<p>\u5728\u672c\u4f8b\u4e2d\uff0c\u6dfb\u52a0\u4e86\u4e00\u4e2a\u4e2d\u95f4\u8868&#8221;t&#8221;\uff0c\u5e76\u6307\u5b9a\u5176\u4e3a\u5b50\u67e5\u8be2\u6d3e\u751f\u8868\u7684\u7ed3\u679c\u3002\u7531\u4e8e&#8221;t&#8221;\u4e0e\u8981\u66f4\u65b0\u7684\u8868&#8221;sys_post&#8221;\u4e0d\u540c\uff0c\u56e0\u6b64\u66f4\u65b0\u64cd\u4f5c\u5f97\u4ee5\u987a\u5229\u6267\u884c\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fMySQL\u5b50\u67e5\u8be2\u66f4\u65b0\u8868\u65f6\u4e3a\u4f55\u52a0\u4e00\u5c42\u5305\u88f9\u80fd\u89e3\u51b3\u62a5\u9519\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>SQL\u5b50\u67e5\u8be2\u66f4\u65b0\u8868\u65f6\u52a0\u4e00\u5c42\u5305\u88f9\u4e3a\u4f55\u594f\u6548\uff1f \u5728MySQL\u4e2d\uff0c\u66f4\u65b0\u8bed\u53e5\uff08\u5982DELETE\u3001INSERT\u3001UPDATE\uff09\u9700\u8981\u66f4\u65b0\u7684\u8868\u548c\u5b50\u67e5\u8be2\u4e2d\u7684FROM\u8868\u4e0d\u80fd\u76f8\u540c\u3002\u8fd9\u5bfc\u81f4\u4e86\u4ee5\u4e0bSQL\u8bed\u53e5\u62a5\u9519\uff1a&#8221;delete FROM sys_post WHERE post_id NOT IN (SELECT MIN(post_id) AS min_id FROM sys_post GROUP BY post_name);\u201d\u3002 \u7136\u800c\uff0c\u901a\u8fc7\u7ed9\u5b50\u67e5\u8be2\u52a0\u4e00\u5c42\u62ec\u53f7\u5305\u88f9\uff0c\u95ee\u9898\u5f97\u4ee5\u89e3\u51b3\uff1a&#8221;delete FROM sys_post WHERE post_id NOT IN (SELECT t.min_id FROM (SELECT MIN(post_id) AS min_id FROM sys_post GROUP BY post_name) t);\u201d\u3002 \u8fd9\u4e00\u8bbe\u8ba1\u7684\u7f18\u7531\u6765\u81eaMySQL\u81ea\u8eab\u7684\u673a\u5236\u9650\u5236\uff0c\u5176\u4ed6\u6570\u636e\u5e93\u6ca1\u6709\u8fd9\u6837\u7684\u7ea6\u675f\u3002\u6839\u636e\u5b98\u65b9\u6587\u6863\uff0c\u66f4\u65b0\u8bed\u53e5\u548c\u5b50\u67e5\u8be2FROM\u4e2d\u7684\u8868\u4e0d\u80fd\u6307\u5411\u540c\u4e00\u5f20\u8868\u3002 \u4e3a\u4e86\u7ed5\u5f00\u8fd9\u4e00\u7ea6\u675f\uff0cMySQL\u63d0\u4f9b\u4e86\u4e00\u4e2a\u89e3\u51b3\u65b9\u6cd5\uff1a\u521b\u5efa\u4e00\u5f20\u4e2d\u95f4\u8868\uff08\u884d\u751f\u8868\uff09\u5e76\u4e3a\u5176\u6307\u5b9a\u4e00\u4e2a\u522b\u540d\uff0c\u7136\u540e\u5728\u5b50\u67e5\u8be2\u4e2d\u4f7f\u7528\u8be5\u522b\u540d\u3002 \u5728\u672c\u4f8b\u4e2d\uff0c\u6dfb\u52a0\u4e86\u4e00\u4e2a\u4e2d\u95f4\u8868&#8221;t&#8221;\uff0c\u5e76\u6307\u5b9a\u5176\u4e3a\u5b50\u67e5\u8be2\u6d3e\u751f\u8868\u7684\u7ed3\u679c\u3002\u7531\u4e8e&#8221;t&#8221;\u4e0e\u8981\u66f4\u65b0\u7684\u8868&#8221;sys_post&#8221;\u4e0d\u540c\uff0c\u56e0\u6b64\u66f4\u65b0\u64cd\u4f5c\u5f97\u4ee5\u987a\u5229\u6267\u884c\u3002 \u4ee5\u4e0a\u5c31\u662fMySQL\u5b50\u67e5\u8be2\u66f4\u65b0\u8868\u65f6\u4e3a\u4f55\u52a0\u4e00\u5c42\u5305\u88f9\u80fd\u89e3\u51b3\u62a5\u9519\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},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-27001","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27001","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=27001"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27001\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=27001"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=27001"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=27001"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}