{"id":64501,"date":"2025-05-03T16:39:42","date_gmt":"2025-05-03T08:39:42","guid":{"rendered":"https:\/\/fwq.ai\/blog\/64501\/"},"modified":"2025-05-03T16:39:42","modified_gmt":"2025-05-03T08:39:42","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-left-join-%e6%93%8d%e4%bd%9c%e7%ac%a6%e5%9c%a8-java-sql-%e4%b8%ad%e6%9f%a5%e8%af%a2%e5%a4%9a%e4%b8%aa%e8%a1%a8%e5%b9%b6%e8%bf%94%e5%9b%9e%e7%89%b9%e5%ae%9a-3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/64501\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 LEFT JOIN \u64cd\u4f5c\u7b26\u5728 Java SQL \u4e2d\u67e5\u8be2\u591a\u4e2a\u8868\u5e76\u8fd4\u56de\u7279\u5b9a\u5b57\u6bb5\uff0c\u907f\u514d\u8fd4\u56de Null \u503c\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173064314564230.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 LEFT JOIN \u64cd\u4f5c\u7b26\u5728 Java SQL \u4e2d\u67e5\u8be2\u591a\u4e2a\u8868\u5e76\u8fd4\u56de\u7279\u5b9a\u5b57\u6bb5\uff0c\u907f\u514d\u8fd4\u56de Null \u503c\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 LEFT JOIN \u64cd\u4f5c\u7b26\u5728 Java SQL \u4e2d\u67e5\u8be2\u591a\u4e2a\u8868\u5e76\u8fd4\u56de\u7279\u5b9a\u5b57\u6bb5\uff0c\u907f\u514d\u8fd4\u56de Null \u503c\uff1f\u63d2\u56fe\" \/><\/p>\n<p>\u5728 java sql \u4e2d\uff0c\u67e5\u8be2\u591a\u4e2a\u8868\u5e76\u8fd4\u56de\u7279\u5b9a\u5b57\u6bb5\u9700\u8981\u4f7f\u7528 join \u64cd\u4f5c\u7b26\u3002\u4e3a\u4e86\u8fd4\u56de\u53ea\u5305\u542b\u6307\u5b9a\u5b57\u6bb5\u7684\u67e5\u8be2\u7ed3\u679c\uff0c\u53ef\u4ee5\u4f7f\u7528 select \u5b50\u53e5\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<pre>select column1, column2, column3\nfrom table1\njoin table2 on table1.key = table2.key\nwhere condition;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff1a<\/p>\n<ul>\n<li>column1, column2, column3 \u662f\u8981\u8fd4\u56de\u7684\u5b57\u6bb5\u3002<\/li>\n<li>table1 \u548c table2 \u662f\u8981\u5173\u8054\u7684\u8868\u3002<\/li>\n<li>table1.key = table2.key \u662f\u8fde\u63a5\u4e24\u4e2a\u8868\u7684\u952e\u3002<\/li>\n<li>where condition \u662f\u7528\u4e8e\u8fc7\u6ee4\u7ed3\u679c\u7684\u53ef\u9009\u6761\u4ef6\u3002<\/li>\n<\/ul>\n<p>\u5728\u60a8\u63d0\u4f9b\u7684\u793a\u4f8b\u4e2d\uff0ca \u8868\u4e2d\u7f3a\u5c11 status \u5b57\u6bb5\uff0c\u5bfc\u81f4 b \u8868\u4e2d\u8fd4\u56de null \u503c\u3002\u8981\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 left join \u64cd\u4f5c\u7b26\uff0c\u5b83\u5c06\u5141\u8bb8\u8fd4\u56de\u8868 b \u4e2d\u7684\u6240\u6709\u8bb0\u5f55\uff0c\u5373\u4f7f\u8868 a \u4e2d\u6ca1\u6709\u5339\u914d\u7684\u8bb0\u5f55\u3002<\/p>\n<p>\u4fee\u6539\u540e\u7684\u67e5\u8be2\u5982\u4e0b\uff1a<\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<pre>SELECT table1.name, table2.status\nFROM table1\nLEFT JOIN table2 ON table1.key = table2.key;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u73b0\u5728\uff0c\u5373\u4f7f\u8868 a \u4e2d\u6ca1\u6709 name \u5b57\u6bb5\uff0c\u67e5\u8be2\u4ecd\u7136\u4f1a\u8fd4\u56de\u8868 b \u4e2d\u7684 status \u5b57\u6bb5\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 LEFT JOIN \u64cd\u4f5c\u7b26\u5728 Java SQL \u4e2d\u67e5\u8be2\u591a\u4e2a\u8868\u5e76\u8fd4\u56de\u7279\u5b9a\u5b57\u6bb5\uff0c\u907f\u514d\u8fd4\u56de Null \u503c\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8IDCBABY\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5728 java sql \u4e2d\uff0c\u67e5\u8be2\u591a\u4e2a\u8868\u5e76\u8fd4\u56de\u7279\u5b9a\u5b57\u6bb5\u9700\u8981\u4f7f\u7528 join \u64cd\u4f5c\u7b26\u3002\u4e3a\u4e86\u8fd4\u56de\u53ea\u5305\u542b\u6307\u5b9a\u5b57\u6bb5\u7684\u67e5\u8be2\u7ed3\u679c\uff0c\u53ef\u4ee5\u4f7f\u7528 select \u5b50\u53e5\uff0c\u5982\u4e0b\u6240\u793a\uff1a select column1, column2, column3 from table1 join table2 on table1.key = table2.key where condition; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a column1, column2, column3 \u662f\u8981\u8fd4\u56de\u7684\u5b57\u6bb5\u3002 table1 \u548c table2 \u662f\u8981\u5173\u8054\u7684\u8868\u3002 table1.key = table2.key \u662f\u8fde\u63a5\u4e24\u4e2a\u8868\u7684\u952e\u3002 where condition \u662f\u7528\u4e8e\u8fc7\u6ee4\u7ed3\u679c\u7684\u53ef\u9009\u6761\u4ef6\u3002 \u5728\u60a8\u63d0\u4f9b\u7684\u793a\u4f8b\u4e2d\uff0ca \u8868\u4e2d\u7f3a\u5c11 status \u5b57\u6bb5\uff0c\u5bfc\u81f4 b \u8868\u4e2d\u8fd4\u56de null \u503c\u3002\u8981\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 left join \u64cd\u4f5c\u7b26\uff0c\u5b83\u5c06\u5141\u8bb8\u8fd4\u56de\u8868 b \u4e2d\u7684\u6240\u6709\u8bb0\u5f55\uff0c\u5373\u4f7f\u8868 a \u4e2d\u6ca1\u6709\u5339\u914d\u7684\u8bb0\u5f55\u3002 \u4fee\u6539\u540e\u7684\u67e5\u8be2\u5982\u4e0b\uff1a [&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-64501","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/64501","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=64501"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/64501\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=64501"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=64501"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=64501"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}