{"id":7652,"date":"2024-11-14T09:04:00","date_gmt":"2024-11-14T01:04:00","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7652\/"},"modified":"2024-11-14T09:04:00","modified_gmt":"2024-11-14T01:04:00","slug":"%e5%9c%a8-mysql-%e4%b8%ad%ef%bc%8c%e4%b8%ba%e4%bb%80%e4%b9%88%e4%b8%8d%e8%83%bd%e5%9c%a8%e5%ad%90%e6%9f%a5%e8%af%a2%e7%9a%84-from-%e5%ad%90%e5%8f%a5%e4%b8%ad%e6%9b%b4%e6%96%b0%e5%bd%93%e5%89%8d","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7652\/","title":{"rendered":"\u5728 MySQL \u4e2d\uff0c\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u5728\u5b50\u67e5\u8be2\u7684 from \u5b50\u53e5\u4e2d\u66f4\u65b0\u5f53\u524d\u67e5\u8be2\u7684\u8868\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173111873740431.jpg\" class=\"aligncenter\" title=\"\u5728 MySQL \u4e2d\uff0c\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u5728\u5b50\u67e5\u8be2\u7684 from \u5b50\u53e5\u4e2d\u66f4\u65b0\u5f53\u524d\u67e5\u8be2\u7684\u8868\uff1f\u63d2\u56fe\" alt=\"\u5728 MySQL \u4e2d\uff0c\u4e3a\u4ec0\u4e48\u4e0d\u80fd\u5728\u5b50\u67e5\u8be2\u7684 from \u5b50\u53e5\u4e2d\u66f4\u65b0\u5f53\u524d\u67e5\u8be2\u7684\u8868\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>SQL \u67e5\u8be2\u8868\u5185\u4e0d\u91cd\u590d\u8bb0\u5f55\u7684\u795e\u79d8\u5305\u88f9<\/strong><\/p>\n<p>\u5728\u6267\u884c SQL \u67e5\u8be2\u8bed\u53e5\u65f6\uff0c\u4f60\u53ef\u80fd\u4f1a\u9047\u5230\u8fd9\u6837\u7684\u9519\u8bef\uff1a&#8221;SQL \u9519\u8bef [1093] [HY000]: You can&#8217;t specify target table &#8216;sys_post&#8217; for update in FROM clause&#8221;\u3002\u8fd9\u901a\u5e38\u662f\u56e0\u4e3a\u4f60\u8bd5\u56fe\u5728\u4e00\u4e2a\u5b50\u67e5\u8be2\u7684 from \u5b50\u53e5\u4e2d\u66f4\u65b0\u5f53\u524d\u6b63\u5728\u67e5\u8be2\u7684\u8868\u3002<\/p>\n<p>\u7136\u800c\uff0c\u5982\u679c\u5728\u5b50\u67e5\u8be2\u5468\u56f4\u6dfb\u52a0\u4e00\u5c42\u5305\u88f9\uff0c\u5373\u4f7f\u7528\u4e00\u4e2a\u6d3e\u751f\u8868\u5e76\u901a\u8fc7\u522b\u540d\u5f15\u7528\u8be5\u8868\uff0c\u67e5\u8be2\u5c31\u80fd\u6210\u529f\u6267\u884c\u3002<\/p>\n<p><strong>MySQL \u7684\u7279\u6b8a\u6027<\/strong><\/p>\n<p>\u8fd9\u79cd\u884c\u4e3a\u662f MySQL \u7279\u6709\u7684\u3002\u5176\u4ed6\u5927\u578b\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\uff0c\u5982 Oracle \u548c SQL Server\uff0c\u6ca1\u6709\u8fd9\u6837\u7684\u9650\u5236\u3002<\/p>\n<p><strong>\u5b98\u65b9\u89e3\u91ca<\/strong><\/p>\n<p>MySQL \u5b98\u65b9\u552f\u4e00\u5bf9\u8fd9\u4e00\u884c\u4e3a\u7684\u89e3\u91ca\u662f\uff1a&#8221;You cannot update a table and select directly from the same table in a subquery.&#8221;\uff08\u4f60\u4e0d\u80fd\u66f4\u65b0\u4e00\u4e2a\u8868\u5e76\u5728\u4e00\u4e2a\u5b50\u67e5\u8be2\u4e2d\u76f4\u63a5\u4ece\u540c\u4e00\u5f20\u8868\u4e2d\u9009\u62e9\u3002\uff09<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u5b98\u65b9\u63d0\u4f9b\u7684\u89e3\u51b3\u65b9\u6848\u662f\u4f7f\u7528\u591a\u8868\u66f4\u65b0\uff0c\u5176\u4e2d\u4e00\u4e2a\u8868\u6d3e\u751f\u81ea\u4f60\u5b9e\u9645\u4e0a\u5e0c\u671b\u66f4\u65b0\u7684\u8868\uff0c\u5e76\u4f7f\u7528\u522b\u540d\u5f15\u7528\u6d3e\u751f\u8868\u3002<\/p>\n<p><strong>\u539f\u56e0\u731c\u6d4b<\/strong><\/p>\n<p>\u81f3\u4e8e MySQL \u6709\u8fd9\u6837\u5947\u602a\u7684\u9650\u5236\uff0c\u539f\u56e0\u4e0d\u5f97\u800c\u77e5\u3002\u53ef\u80fd\u662f\u4e3a\u4e86\u9632\u6b62\u4e00\u4e9b\u610f\u5916\u7684\u66f4\u65b0\u6216\u51b2\u7a81\uff0c\u4f46\u5177\u4f53\u7684\u89e3\u91ca\u5b98\u65b9\u5e76\u6ca1\u6709\u7ed9\u51fa\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5728 MySQL \u4e2d\uff0c\u4e0d\u80fd\u5728\u5b50\u67e5\u8be2\u7684 from \u5b50\u53e5\u4e2d\u66f4\u65b0\u5f53\u524d\u67e5\u8be2\u7684\u8868\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>SQL \u67e5\u8be2\u8868\u5185\u4e0d\u91cd\u590d\u8bb0\u5f55\u7684\u795e\u79d8\u5305\u88f9 \u5728\u6267\u884c SQL \u67e5\u8be2\u8bed\u53e5\u65f6\uff0c\u4f60\u53ef\u80fd\u4f1a\u9047\u5230\u8fd9\u6837\u7684\u9519\u8bef\uff1a&#8221;SQL \u9519\u8bef [1093] [HY000]: You can&#8217;t specify target table &#8216;sys_post&#8217; for update in FROM clause&#8221;\u3002\u8fd9\u901a\u5e38\u662f\u56e0\u4e3a\u4f60\u8bd5\u56fe\u5728\u4e00\u4e2a\u5b50\u67e5\u8be2\u7684 from \u5b50\u53e5\u4e2d\u66f4\u65b0\u5f53\u524d\u6b63\u5728\u67e5\u8be2\u7684\u8868\u3002 \u7136\u800c\uff0c\u5982\u679c\u5728\u5b50\u67e5\u8be2\u5468\u56f4\u6dfb\u52a0\u4e00\u5c42\u5305\u88f9\uff0c\u5373\u4f7f\u7528\u4e00\u4e2a\u6d3e\u751f\u8868\u5e76\u901a\u8fc7\u522b\u540d\u5f15\u7528\u8be5\u8868\uff0c\u67e5\u8be2\u5c31\u80fd\u6210\u529f\u6267\u884c\u3002 MySQL \u7684\u7279\u6b8a\u6027 \u8fd9\u79cd\u884c\u4e3a\u662f MySQL \u7279\u6709\u7684\u3002\u5176\u4ed6\u5927\u578b\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\uff0c\u5982 Oracle \u548c SQL Server\uff0c\u6ca1\u6709\u8fd9\u6837\u7684\u9650\u5236\u3002 \u5b98\u65b9\u89e3\u91ca MySQL \u5b98\u65b9\u552f\u4e00\u5bf9\u8fd9\u4e00\u884c\u4e3a\u7684\u89e3\u91ca\u662f\uff1a&#8221;You cannot update a table and select directly from the same table in a subquery.&#8221;\uff08\u4f60\u4e0d\u80fd\u66f4\u65b0\u4e00\u4e2a\u8868\u5e76\u5728\u4e00\u4e2a\u5b50\u67e5\u8be2\u4e2d\u76f4\u63a5\u4ece\u540c\u4e00\u5f20\u8868\u4e2d\u9009\u62e9\u3002\uff09 \u89e3\u51b3\u65b9\u6848 \u5b98\u65b9\u63d0\u4f9b\u7684\u89e3\u51b3\u65b9\u6848\u662f\u4f7f\u7528\u591a\u8868\u66f4\u65b0\uff0c\u5176\u4e2d\u4e00\u4e2a\u8868\u6d3e\u751f\u81ea\u4f60\u5b9e\u9645\u4e0a\u5e0c\u671b\u66f4\u65b0\u7684\u8868\uff0c\u5e76\u4f7f\u7528\u522b\u540d\u5f15\u7528\u6d3e\u751f\u8868\u3002 \u539f\u56e0\u731c\u6d4b \u81f3\u4e8e MySQL \u6709\u8fd9\u6837\u5947\u602a\u7684\u9650\u5236\uff0c\u539f\u56e0\u4e0d\u5f97\u800c\u77e5\u3002\u53ef\u80fd\u662f\u4e3a\u4e86\u9632\u6b62\u4e00\u4e9b\u610f\u5916\u7684\u66f4\u65b0\u6216\u51b2\u7a81\uff0c\u4f46\u5177\u4f53\u7684\u89e3\u91ca\u5b98\u65b9\u5e76\u6ca1\u6709\u7ed9\u51fa\u3002 \u4ee5\u4e0a\u5c31\u662f\u5728 [&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-7652","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7652","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=7652"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7652\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}