{"id":49465,"date":"2024-12-02T14:22:36","date_gmt":"2024-12-02T06:22:36","guid":{"rendered":"https:\/\/fwq.ai\/blog\/49465\/"},"modified":"2024-12-02T14:22:36","modified_gmt":"2024-12-02T06:22:36","slug":"%e5%a6%82%e4%bd%95%e7%94%a8mysql-update%e8%af%ad%e5%8f%a5%e5%92%8cleft-join%e6%9b%b4%e6%96%b0%e5%ad%a6%e7%94%9f%e8%a1%a8%e4%b8%ad%e6%af%8f%e4%b8%aa%e5%ad%a6%e7%94%9f%e7%9a%84%e6%9c%80%e9%ab%98","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/49465\/","title":{"rendered":"\u5982\u4f55\u7528MySQL UPDATE\u8bed\u53e5\u548cLEFT JOIN\u66f4\u65b0\u5b66\u751f\u8868\u4e2d\u6bcf\u4e2a\u5b66\u751f\u7684\u6700\u9ad8\u5206\u6570\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>\u5982\u4f55\u7528MySQL UPDATE\u8bed\u53e5\u548cLEFT JOIN\u66f4\u65b0\u5b66\u751f\u8868\u4e2d\u6bcf\u4e2a\u5b66\u751f\u7684\u6700\u9ad8\u5206\u6570\uff1f<\/h1>\n<p><span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u6587\u7ae0<\/span>\u4e0d\u77e5\u9053\u5927\u5bb6\u662f\u5426\u719f\u6089\uff1f\u4eca\u5929\u6211\u5c06\u7ed9\u5927\u5bb6\u4ecb\u7ecd<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\">\u300a\u5982\u4f55\u7528MySQL UPDATE\u8bed\u53e5\u548cLEFT JOIN\u66f4\u65b0\u5b66\u751f\u8868\u4e2d\u6bcf\u4e2a\u5b66\u751f\u7684\u6700\u9ad8\u5206\u6570\uff1f\u300b<\/span>\uff0c\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4f1a\u8bb2\u5230<span style=\"color: #FF6600;, Helvetica, Arial, sans-serif;font-size: 14px;background-color: #FFFFFF\"><\/span>\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u4f60\u5728\u770b\u5b8c\u672c\u7bc7\u6587\u7ae0\u540e\uff0c\u6709\u66f4\u597d\u7684\u5efa\u8bae\u6216\u8005\u53d1\u73b0\u54ea\u91cc\u6709\u95ee\u9898\uff0c\u5e0c\u671b\u5927\u5bb6\u90fd\u80fd\u79ef\u6781\u8bc4\u8bba\u6307\u51fa\uff0c\u8c22\u8c22\uff01\u5e0c\u671b\u6211\u4eec\u80fd\u4e00\u8d77\u52a0\u6cb9\u8fdb\u6b65\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241202\/1733120923674d539b56cdf.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u7528MySQL UPDATE\u8bed\u53e5\u548cLEFT JOIN\u66f4\u65b0\u5b66\u751f\u8868\u4e2d\u6bcf\u4e2a\u5b66\u751f\u7684\u6700\u9ad8\u5206\u6570\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u7528MySQL UPDATE\u8bed\u53e5\u548cLEFT JOIN\u66f4\u65b0\u5b66\u751f\u8868\u4e2d\u6bcf\u4e2a\u5b66\u751f\u7684\u6700\u9ad8\u5206\u6570\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>mysql update \u8bed\u53e5 left join \u63d0\u53d6\u591a\u6761\u6570\u636e\u4e2d\u7684\u6700\u5927\u5b57\u6bb5\u503c<\/strong><\/p>\n<p><strong>\u95ee\u9898\uff1a<\/strong><\/p>\n<p>\u5bf9\u4e8e student \u8868\u548c score \u8868<\/p>\n<ul>\n<li>student \u8868\u7ed3\u6784\uff1aid, name, score<\/li>\n<li>score \u8868\u7ed3\u6784\uff1aid, student_id, score<\/li>\n<\/ul>\n<p>\u5982\u4f55\u4f7f\u7528 mysql update \u8bed\u53e5\u7ed3\u5408 left join\uff0c\u5c06 student \u8868\u4e2d\u7684 score \u5b57\u6bb5\u66f4\u65b0\u4e3a\u5bf9\u5e94 score \u8868\u4e2d\u6700\u5927\u7684 score \u503c\uff1f<\/p>\n<p><strong>\u89e3\u7b54\uff1a<\/strong><\/p>\n<pre>update student set score=(select max(score) from score where score.student_id=student.id)<\/pre>\n<p>\u4eca\u5929\u5173\u4e8e\u300a\u5982\u4f55\u7528MySQL UPDATE\u8bed\u53e5\u548cLEFT JOIN\u66f4\u65b0\u5b66\u751f\u8868\u4e2d\u6bcf\u4e2a\u5b66\u751f\u7684\u6700\u9ad8\u5206\u6570\uff1f\u300b\u7684\u5185\u5bb9\u4ecb\u7ecd\u5c31\u5230\u6b64\u7ed3\u675f\uff0c\u5982\u679c\u6709\u4ec0\u4e48\u7591\u95ee\u6216\u8005\u5efa\u8bae\uff0c\u53ef\u4ee5\u5728\u7c73\u4e91\u516c\u4f17\u53f7\u4e0b\u591a\u591a\u56de\u590d\u4ea4\u6d41\uff1b\u6587\u4e2d\u82e5\u6709\u4e0d\u6b63\u4e4b\u5904\uff0c\u4e5f\u5e0c\u671b\u56de\u590d\u7559\u8a00\u4ee5\u544a\u77e5\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u7528MySQL UPDATE\u8bed\u53e5\u548cLEFT JOIN\u66f4\u65b0\u5b66\u751f\u8868\u4e2d\u6bcf\u4e2a\u5b66\u751f\u7684\u6700\u9ad8\u5206\u6570\uff1f \u6587\u7ae0\u4e0d\u77e5\u9053\u5927\u5bb6\u662f\u5426\u719f\u6089\uff1f\u4eca\u5929\u6211\u5c06\u7ed9\u5927\u5bb6\u4ecb\u7ecd\u300a\u5982\u4f55\u7528MySQL UPDATE\u8bed\u53e5\u548cLEFT JOIN\u66f4\u65b0\u5b66\u751f\u8868\u4e2d\u6bcf\u4e2a\u5b66\u751f\u7684\u6700\u9ad8\u5206\u6570\uff1f\u300b\uff0c\u8fd9\u7bc7\u6587\u7ae0\u4e3b\u8981\u4f1a\u8bb2\u5230\u7b49\u7b49\u77e5\u8bc6\u70b9\uff0c\u5982\u679c\u4f60\u5728\u770b\u5b8c\u672c\u7bc7\u6587\u7ae0\u540e\uff0c\u6709\u66f4\u597d\u7684\u5efa\u8bae\u6216\u8005\u53d1\u73b0\u54ea\u91cc\u6709\u95ee\u9898\uff0c\u5e0c\u671b\u5927\u5bb6\u90fd\u80fd\u79ef\u6781\u8bc4\u8bba\u6307\u51fa\uff0c\u8c22\u8c22\uff01\u5e0c\u671b\u6211\u4eec\u80fd\u4e00\u8d77\u52a0\u6cb9\u8fdb\u6b65\uff01 mysql update \u8bed\u53e5 left join \u63d0\u53d6\u591a\u6761\u6570\u636e\u4e2d\u7684\u6700\u5927\u5b57\u6bb5\u503c \u95ee\u9898\uff1a \u5bf9\u4e8e student \u8868\u548c score \u8868 student \u8868\u7ed3\u6784\uff1aid, name, score score \u8868\u7ed3\u6784\uff1aid, student_id, score \u5982\u4f55\u4f7f\u7528 mysql update \u8bed\u53e5\u7ed3\u5408 left join\uff0c\u5c06 student \u8868\u4e2d\u7684 score \u5b57\u6bb5\u66f4\u65b0\u4e3a\u5bf9\u5e94 score \u8868\u4e2d\u6700\u5927\u7684 score \u503c\uff1f \u89e3\u7b54\uff1a update student set score=(select max(score) from score where score.student_id=student.id) \u4eca\u5929\u5173\u4e8e\u300a\u5982\u4f55\u7528MySQL UPDATE\u8bed\u53e5\u548cLEFT JOIN\u66f4\u65b0\u5b66\u751f\u8868\u4e2d\u6bcf\u4e2a\u5b66\u751f\u7684\u6700\u9ad8\u5206\u6570\uff1f\u300b\u7684\u5185\u5bb9\u4ecb\u7ecd\u5c31\u5230\u6b64\u7ed3\u675f\uff0c\u5982\u679c\u6709\u4ec0\u4e48\u7591\u95ee\u6216\u8005\u5efa\u8bae\uff0c\u53ef\u4ee5\u5728\u7c73\u4e91\u516c\u4f17\u53f7\u4e0b\u591a\u591a\u56de\u590d\u4ea4\u6d41\uff1b\u6587\u4e2d\u82e5\u6709\u4e0d\u6b63\u4e4b\u5904\uff0c\u4e5f\u5e0c\u671b\u56de\u590d\u7559\u8a00\u4ee5\u544a\u77e5\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-49465","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49465","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=49465"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/49465\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=49465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=49465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=49465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}