{"id":25652,"date":"2024-11-24T12:13:14","date_gmt":"2024-11-24T04:13:14","guid":{"rendered":"https:\/\/fwq.ai\/blog\/25652\/"},"modified":"2024-11-24T12:13:14","modified_gmt":"2024-11-24T04:13:14","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8sql%e8%af%ad%e5%8f%a5%e5%8e%bb%e9%99%a4%e8%81%94%e8%a1%a8%e6%9f%a5%e8%af%a2%e4%b8%ad%e7%9a%84%e9%87%8d%e5%a4%8d%e5%ad%97%e6%ae%b5%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/25652\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528SQL\u8bed\u53e5\u53bb\u9664\u8054\u8868\u67e5\u8be2\u4e2d\u7684\u91cd\u590d\u5b57\u6bb5\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173064584050379.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528SQL\u8bed\u53e5\u53bb\u9664\u8054\u8868\u67e5\u8be2\u4e2d\u7684\u91cd\u590d\u5b57\u6bb5\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528SQL\u8bed\u53e5\u53bb\u9664\u8054\u8868\u67e5\u8be2\u4e2d\u7684\u91cd\u590d\u5b57\u6bb5\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>sql\u67e5\u8be2\u53bb\u9664\u91cd\u590d\u5b57\u6bb5<\/strong><\/p>\n<p>\u5728sql\u8054\u8868\u67e5\u8be2\u4e2d\uff0c\u5982\u679c\u51fa\u73b0\u91cd\u590d\u5b57\u6bb5\uff0c\u901a\u5e38\u53ef\u4ee5\u901a\u8fc7\u5728select\u8bed\u53e5\u4e2d\u6307\u5b9a\u8981\u67e5\u8be2\u7684\u5b57\u6bb5\u6765\u53bb\u9664\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>select s_id, s_name, sco_id, sco_subject from student stu left join score sco on stu.s_id = sco.s_id;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4f46\u8fd9\u5e76\u4e0d\u662f\u53bb\u9664\u91cd\u590d\u5b57\u6bb5\u7684\u552f\u4e00\u65b9\u6cd5\u3002\u8fd8\u6709\u4e00\u79cd\u65b9\u6cd5\u662f\u4f7f\u7528using\u5173\u952e\u5b57\uff0c\u5b83\u53ef\u4ee5\u6307\u5b9a\u8fde\u63a5\u8868\u4e4b\u95f4\u7684\u8fde\u63a5\u4f9d\u636e\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>SELECT * FROM student stu LEFT JOIN score sco USING (s_id);<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0cusing\u5173\u952e\u5b57\u6307\u5b9a\u4e86s_id\u5b57\u6bb5\u662f\u4e24\u4e2a\u8868\u4e4b\u95f4\u7684\u8fde\u63a5\u4f9d\u636e\u3002\u56e0\u6b64\uff0c\u7ed3\u679c\u96c6\u4e2d\u5c06\u53ea\u663e\u793a\u4e00\u4e2as_id\u5b57\u6bb5\uff0c\u91cd\u590d\u7684\u5b57\u6bb5\u5c06\u88ab\u53bb\u9664\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528SQL\u8bed\u53e5\u53bb\u9664\u8054\u8868\u67e5\u8be2\u4e2d\u7684\u91cd\u590d\u5b57\u6bb5\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\u67e5\u8be2\u53bb\u9664\u91cd\u590d\u5b57\u6bb5 \u5728sql\u8054\u8868\u67e5\u8be2\u4e2d\uff0c\u5982\u679c\u51fa\u73b0\u91cd\u590d\u5b57\u6bb5\uff0c\u901a\u5e38\u53ef\u4ee5\u901a\u8fc7\u5728select\u8bed\u53e5\u4e2d\u6307\u5b9a\u8981\u67e5\u8be2\u7684\u5b57\u6bb5\u6765\u53bb\u9664\u3002\u4f8b\u5982\uff1a select s_id, s_name, sco_id, sco_subject from student stu left join score sco on stu.s_id = sco.s_id; \u767b\u5f55\u540e\u590d\u5236 \u4f46\u8fd9\u5e76\u4e0d\u662f\u53bb\u9664\u91cd\u590d\u5b57\u6bb5\u7684\u552f\u4e00\u65b9\u6cd5\u3002\u8fd8\u6709\u4e00\u79cd\u65b9\u6cd5\u662f\u4f7f\u7528using\u5173\u952e\u5b57\uff0c\u5b83\u53ef\u4ee5\u6307\u5b9a\u8fde\u63a5\u8868\u4e4b\u95f4\u7684\u8fde\u63a5\u4f9d\u636e\u3002\u4f8b\u5982\uff1a SELECT * FROM student stu LEFT JOIN score sco USING (s_id); \u767b\u5f55\u540e\u590d\u5236 \u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0cusing\u5173\u952e\u5b57\u6307\u5b9a\u4e86s_id\u5b57\u6bb5\u662f\u4e24\u4e2a\u8868\u4e4b\u95f4\u7684\u8fde\u63a5\u4f9d\u636e\u3002\u56e0\u6b64\uff0c\u7ed3\u679c\u96c6\u4e2d\u5c06\u53ea\u663e\u793a\u4e00\u4e2as_id\u5b57\u6bb5\uff0c\u91cd\u590d\u7684\u5b57\u6bb5\u5c06\u88ab\u53bb\u9664\u3002 \u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528SQL\u8bed\u53e5\u53bb\u9664\u8054\u8868\u67e5\u8be2\u4e2d\u7684\u91cd\u590d\u5b57\u6bb5\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-25652","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/25652","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=25652"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/25652\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=25652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=25652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=25652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}