{"id":200301,"date":"2025-05-06T11:30:55","date_gmt":"2025-05-06T03:30:55","guid":{"rendered":"https:\/\/server.hk\/cnblog\/200301\/"},"modified":"2025-05-06T11:30:55","modified_gmt":"2025-05-06T03:30:55","slug":"mysql-join-%e4%b8%b4%e6%97%b6%e8%a1%a8%e5%ad%97%e6%ae%b5%ef%bc%9a%e5%86%85%e8%bf%9e%e6%8e%a5%e6%97%b6%ef%bc%8c%e4%b8%b4%e6%97%b6%e8%a1%a8%e5%ad%97%e6%ae%b5%e4%bc%9a%e5%8c%85%e5%90%ab%e5%93%aa%e4%ba%9b","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/200301\/","title":{"rendered":"MySQL Join \u4e34\u65f6\u8868\u5b57\u6bb5\uff1a\u5185\u8fde\u63a5\u65f6\uff0c\u4e34\u65f6\u8868\u5b57\u6bb5\u4f1a\u5305\u542b\u54ea\u4e9b\u5185\u5bb9\uff1f"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>MySQL Join \u4e34\u65f6\u8868\u5b57\u6bb5\uff1a\u5185\u8fde\u63a5\u65f6\uff0c\u4e34\u65f6\u8868\u5b57\u6bb5\u4f1a\u5305\u542b\u54ea\u4e9b\u5185\u5bb9\uff1f<\/h1>\n<p>\u4e00\u5206\u8015\u8018\uff0c\u4e00\u5206\u6536\u83b7\uff01\u65e2\u7136\u6253\u5f00\u4e86\u8fd9\u7bc7\u6587\u7ae0\uff0c\u5c31\u575a\u6301\u770b\u4e0b\u53bb\u5427\uff01\u6587\u4e2d\u5185\u5bb9\u5305\u542b\u7b49\u7b49\u77e5\u8bc6\u70b9&#8230;\u5e0c\u671b\u4f60\u80fd\u5728\u9605\u8bfb\u672c\u6587\u540e\uff0c\u80fd\u771f\u771f\u5b9e\u5b9e\u5b66\u5230\u77e5\u8bc6\u6216\u8005\u5e2e\u4f60\u89e3\u51b3\u5fc3\u4e2d\u7684\u7591\u60d1\uff0c\u4e5f\u6b22\u8fce\u5927\u4f6c\u6216\u8005\u65b0\u4eba\u670b\u53cb\u4eec\u591a\u7559\u8a00\u8bc4\u8bba\uff0c\u591a\u7ed9\u5efa\u8bae\uff01\u8c22\u8c22\uff01<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241101\/173041924767241a2fde7df.jpg\" class=\"aligncenter\"><\/p>\n<p><strong>MySQL Join \u4e34\u65f6\u8868\u5b57\u6bb5\u7591\u7aa6<\/strong><\/p>\n<p>\u5047\u8bbe\u8868 A \u548c\u8868 B \u90fd\u6709 4 \u4e2a\u5b57\u6bb5\u3002\u73b0\u5728\u6267\u884c\u4e00\u6761 SQL \u8bed\u53e5\uff0c\u5c06\u8868 A \u4e0e\u8868 B \u5728 a_id \u5217\u4e0a\u8fdb\u884c\u5185\u8fde\u63a5\uff0c\u5e76\u8fc7\u6ee4\u51fa\u8868 B \u4e2d delete_sign \u4e3a 0 \u7684\u8bb0\u5f55\u3002<\/p>\n<p>\u95ee\u9898\uff1aMySQL \u6267\u884c SQL \u8bed\u53e5\u65f6\u751f\u6210\u7684\u4e34\u65f6\u8868\u5b57\u6bb5\u4f1a\u662f\u4ee5\u4e0b\u54ea\u79cd\u60c5\u51b5\uff1f<\/p>\n<p><strong>\u9009\u9879 A\uff1a\u4e34\u65f6\u8868 M<\/strong><\/p>\n<table>\n<thead>\n<tr>\n<th>\u5b57\u6bb5<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>A.id<\/td>\n<\/tr>\n<tr>\n<td>A.name<\/td>\n<\/tr>\n<tr>\n<td>A.staus<\/td>\n<\/tr>\n<tr>\n<td>A.delete_sign<\/td>\n<\/tr>\n<tr>\n<td>B.id<\/td>\n<\/tr>\n<tr>\n<td>B.a_id<\/td>\n<\/tr>\n<tr>\n<td>B.staus<\/td>\n<\/tr>\n<tr>\n<td>B.delete_sign<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>\u9009\u9879 B\uff1a\u4e34\u65f6\u8868 N<\/strong><\/p>\n<table>\n<thead>\n<tr>\n<th>\u5b57\u6bb5<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>A.id<\/td>\n<\/tr>\n<tr>\n<td>A.name<\/td>\n<\/tr>\n<tr>\n<td>A.staus<\/td>\n<\/tr>\n<tr>\n<td>A.delete_sign<\/td>\n<\/tr>\n<tr>\n<td>B.delete_sign<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u7b54\u6848\uff1a<strong>\u4e34\u65f6\u8868 N<\/strong><\/p>\n<p>\u6839\u636e\u5173\u7cfb\u4ee3\u6570\u4e2d\u7684\u81ea\u7136\u8fde\u63a5\u5b9a\u4e49\uff0c\u4e34\u65f6\u8868 N \u662f\u6b63\u786e\u7684\u9009\u62e9\u3002\u4e34\u65f6\u8868 N \u4ec5\u5305\u542b\u8868 A \u548c\u8868 B \u7684\u8fde\u63a5\u5217\uff08\u5373 a_id\uff09\u4ee5\u53ca\u7528\u4e8e\u786e\u5b9a\u8fde\u63a5\u5173\u7cfb\u7684\u8868 B \u4e2d\u7684\u8fc7\u6ee4\u6761\u4ef6\u5b57\u6bb5\uff08\u5373 delete_sign\uff09\u3002<\/p>\n<p>\u672c\u7bc7\u5173\u4e8e\u300aMySQL Join \u4e34\u65f6\u8868\u5b57\u6bb5\uff1a\u5185\u8fde\u63a5\u65f6\uff0c\u4e34\u65f6\u8868\u5b57\u6bb5\u4f1a\u5305\u542b\u54ea\u4e9b\u5185\u5bb9\uff1f\u300b\u7684\u4ecb\u7ecd\u5c31\u5230\u6b64\u7ed3\u675f\u5566\uff0c\u4f46\u662f\u5b66\u65e0\u6b62\u5883\uff0c\u60f3\u8981\u4e86\u89e3\u5b66\u4e60\u66f4\u591a\u5173\u4e8e\u6570\u636e\u5e93\u7684\u76f8\u5173\u77e5\u8bc6\uff0c\u8bf7\u5173\u6ce8\u4e3b\u673a\u5b9d\u8d1d\u516c\u4f17\u53f7\uff01<\/p>\n<dl>\n<dt>\n <\/dt>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>MySQL Join \u4e34\u65f6\u8868\u5b57\u6bb5&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-200301","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=200301"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200301\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=200301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=200301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=200301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}