{"id":7342,"date":"2024-11-14T12:10:34","date_gmt":"2024-11-14T04:10:34","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7342\/"},"modified":"2024-11-14T12:10:34","modified_gmt":"2024-11-14T04:10:34","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-left-join-%e6%9b%b4%e6%96%b0-student-%e8%a1%a8%e4%b8%ad-score-%e5%ad%97%e6%ae%b5%e4%b8%ba%e5%af%b9%e5%ba%94-score-%e8%a1%a8%e4%b8%ad%e6%9c%80%e5%a4%a7%e5%80%bc","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7342\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 left join \u66f4\u65b0 student \u8868\u4e2d score \u5b57\u6bb5\u4e3a\u5bf9\u5e94 score \u8868\u4e2d\u6700\u5927\u503c\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173072091448677.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 left join \u66f4\u65b0 student \u8868\u4e2d score \u5b57\u6bb5\u4e3a\u5bf9\u5e94 score \u8868\u4e2d\u6700\u5927\u503c\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 left join \u66f4\u65b0 student \u8868\u4e2d score \u5b57\u6bb5\u4e3a\u5bf9\u5e94 score \u8868\u4e2d\u6700\u5927\u503c\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u4f7f\u7528left join\u66f4\u65b0\u8868\u4e2d\u591a\u6761\u6570\u636e\u4e2d\u7684\u6700\u5927\u503c<\/strong><\/p>\n<p><strong>\u95ee\u9898\uff1a<\/strong><\/p>\n<p>\u5982\u4f55\u5c06student\u8868\u4e2dscore\u5b57\u6bb5\u66f4\u65b0\u4e3a\u5bf9\u5e94score\u8868\u4e2d\u6700\u5927\u503c\u7684score\uff1f<\/p>\n<p><strong>\u6570\u636e\u7ed3\u6784\uff1a<\/strong><\/p>\n<ul>\n<li>student\u8868\uff1aid\u3001name\u3001score<\/li>\n<li>score\u8868\uff1aid\u3001student_id\u3001score<\/li>\n<\/ul>\n<p><strong>\uff1a<\/strong><\/p>\n<pre>update student set score=(select max(score) from score where score.student_id=student.id)<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u8bf4\u660e\uff1a<\/strong><\/p>\n<p>\u8be5sql\u8bed\u53e5\u4f7f\u7528left join\u8fde\u63a5student\u8868\u548cscore\u8868\uff0c\u6839\u636estudent.id\u548cscore.student_id\u5b57\u6bb5\u8fdb\u884c\u5339\u914d\u3002\u5bf9\u4e8e\u6bcf\u4e2astudent\u8868\u4e2d\u7684\u8bb0\u5f55\uff0c\u5b83\u4f1a\u4ecescore\u8868\u4e2d\u83b7\u53d6\u5173\u8054\u7684score\u503c\u7684\u5217\u8868\uff0c\u7136\u540e\u4f7f\u7528max()\u51fd\u6570\u8ba1\u7b97\u5217\u8868\u4e2d\u7684\u6700\u5927\u503c\u3002\u6700\u540e\uff0c\u5c06\u6700\u5927\u503c\u66f4\u65b0\u5230student\u8868\u7684score\u5b57\u6bb5\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 left join \u66f4\u65b0 student \u8868\u4e2d score \u5b57\u6bb5\u4e3a\u5bf9\u5e94 score \u8868\u4e2d\u6700\u5927\u503c\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>\u4f7f\u7528left join\u66f4\u65b0\u8868\u4e2d\u591a\u6761\u6570\u636e\u4e2d\u7684\u6700\u5927\u503c \u95ee\u9898\uff1a \u5982\u4f55\u5c06student\u8868\u4e2dscore\u5b57\u6bb5\u66f4\u65b0\u4e3a\u5bf9\u5e94score\u8868\u4e2d\u6700\u5927\u503c\u7684score\uff1f \u6570\u636e\u7ed3\u6784\uff1a student\u8868\uff1aid\u3001name\u3001score score\u8868\uff1aid\u3001student_id\u3001score \uff1a update student set score=(select max(score) from score where score.student_id=student.id) \u767b\u5f55\u540e\u590d\u5236 \u8bf4\u660e\uff1a \u8be5sql\u8bed\u53e5\u4f7f\u7528left join\u8fde\u63a5student\u8868\u548cscore\u8868\uff0c\u6839\u636estudent.id\u548cscore.student_id\u5b57\u6bb5\u8fdb\u884c\u5339\u914d\u3002\u5bf9\u4e8e\u6bcf\u4e2astudent\u8868\u4e2d\u7684\u8bb0\u5f55\uff0c\u5b83\u4f1a\u4ecescore\u8868\u4e2d\u83b7\u53d6\u5173\u8054\u7684score\u503c\u7684\u5217\u8868\uff0c\u7136\u540e\u4f7f\u7528max()\u51fd\u6570\u8ba1\u7b97\u5217\u8868\u4e2d\u7684\u6700\u5927\u503c\u3002\u6700\u540e\uff0c\u5c06\u6700\u5927\u503c\u66f4\u65b0\u5230student\u8868\u7684score\u5b57\u6bb5\u3002 \u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 left join \u66f4\u65b0 student \u8868\u4e2d score \u5b57\u6bb5\u4e3a\u5bf9\u5e94 score \u8868\u4e2d\u6700\u5927\u503c\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},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-7342","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7342","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=7342"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7342\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}