{"id":217776,"date":"2023-12-23T00:04:21","date_gmt":"2023-12-22T16:04:21","guid":{"rendered":"https:\/\/www.idc.net\/help\/217776\/"},"modified":"2023-12-23T00:04:21","modified_gmt":"2023-12-22T16:04:21","slug":"mysql%e4%bd%bf%e7%94%a8%e6%89%8b%e5%86%8c%ef%bc%9a%e4%bd%bf%e7%94%a8inner-join%e5%85%b3%e9%94%ae%e5%ad%97%e8%bf%94%e5%9b%9e%e4%b8%a4%e4%b8%aa%e8%a1%a8%e4%b8%ad%e9%83%bd%e6%9c%89%e5%8c%b9%e9%85%8d","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/217776\/","title":{"rendered":"MySQL\u4f7f\u7528\u624b\u518c\uff1a\u4f7f\u7528INNER JOIN\u5173\u952e\u5b57\u8fd4\u56de\u4e24\u4e2a\u8868\u4e2d\u90fd\u6709\u5339\u914d\u503c\u7684\u884c"},"content":{"rendered":"<p><title id=\"mysql%e4%bd%bf%e7%94%a8%e6%89%8b%e5%86%8c%ef%bc%9a%e4%bd%bf%e7%94%a8inner-join%e5%85%b3%e9%94%ae%e5%ad%97%e8%bf%94%e5%9b%9e%e4%b8%a4%e4%b8%aa%e8%a1%a8%e4%b8%ad%e9%83%bd%e6%9c%89%e5%8c%b9%e9%85%8d-DrNHLgmpXE\">MySQL\u4f7f\u7528\u624b\u518c\uff1a\u4f7f\u7528INNER JOIN\u5173\u952e\u5b57\u8fd4\u56de\u4e24\u4e2a\u8868\u4e2d\u90fd\u6709\u5339\u914d\u503c\u7684\u884c<\/title><\/p>\n<h1 id=\"mysql%e4%bd%bf%e7%94%a8%e6%89%8b%e5%86%8c%ef%bc%9a%e4%bd%bf%e7%94%a8inner-join%e5%85%b3%e9%94%ae%e5%ad%97%e8%bf%94%e5%9b%9e%e4%b8%a4%e4%b8%aa%e8%a1%a8%e4%b8%ad%e9%83%bd%e6%9c%89%e5%8c%b9%e9%85%8d-DrNHLgmpXE\">MySQL\u4f7f\u7528\u624b\u518c\uff1a\u4f7f\u7528INNER JOIN\u5173\u952e\u5b57\u8fd4\u56de\u4e24\u4e2a\u8868\u4e2d\u90fd\u6709\u5339\u914d\u503c\u7684\u884c<\/h1>\n<p>\u5728MySQL\u4e2d\uff0cINNER JOIN\u662f\u4e00\u79cd\u7528\u4e8e\u4ece\u4e24\u4e2a\u6216\u591a\u4e2a\u8868\u4e2d\u8fd4\u56de\u5339\u914d\u884c\u7684\u5173\u952e\u5b57\u3002\u5b83\u57fa\u4e8e\u4e24\u4e2a\u8868\u4e4b\u95f4\u7684\u5171\u540c\u5217\u503c\u8fdb\u884c\u5339\u914d\uff0c\u5e76\u8fd4\u56de\u8fd9\u4e9b\u8868\u4e2d\u90fd\u6709\u5339\u914d\u503c\u7684\u884c\u3002<\/p>\n<p>INNER JOIN\u7684\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre><code>SELECT column_name(s)\nFROM table1\nINNER JOIN table2\nON table1.column_name = table2.column_name;<\/code><\/pre>\n<p>\u5728\u8fd9\u4e2a\u8bed\u6cd5\u4e2d\uff0c<code>table1<\/code>\u548c<code>table2<\/code>\u662f\u8981\u8fde\u63a5\u7684\u4e24\u4e2a\u8868\u7684\u540d\u79f0\uff0c<code>column_name<\/code>\u662f\u8fd9\u4e24\u4e2a\u8868\u4e2d\u7528\u4e8e\u5339\u914d\u7684\u5217\u7684\u540d\u79f0\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u4e00\u4e2a\u793a\u4f8b\uff0c\u6f14\u793a\u5982\u4f55\u4f7f\u7528INNER JOIN\u5173\u952e\u5b57\u8fd4\u56de\u4e24\u4e2a\u8868\u4e2d\u90fd\u6709\u5339\u914d\u503c\u7684\u884c\uff1a<\/p>\n<pre><code>SELECT Customers.CustomerName, Orders.OrderID\nFROM Customers\nINNER JOIN Orders\nON Customers.CustomerID = Orders.CustomerID;<\/code><\/pre>\n<p>\u5728\u8fd9\u4e2a\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u6709\u4e24\u4e2a\u8868\uff1aCustomers\u548cOrders\u3002\u6211\u4eec\u60f3\u8981\u8fd4\u56de\u90a3\u4e9b\u5728\u8fd9\u4e24\u4e2a\u8868\u4e2d\u90fd\u6709\u5339\u914d\u503c\u7684\u884c\uff0c\u6240\u4ee5\u6211\u4eec\u4f7f\u7528\u4e86INNER JOIN\u5173\u952e\u5b57\uff0c\u5e76\u6307\u5b9a\u4e86\u7528\u4e8e\u5339\u914d\u7684\u5217\u662fCustomerID\u3002<\/p>\n<p>INNER JOIN\u5173\u952e\u5b57\u5c06\u8fd4\u56de\u4e00\u4e2a\u5305\u542b\u4e24\u4e2a\u8868\u4e2d\u5339\u914d\u884c\u7684\u7ed3\u679c\u96c6\u3002\u5728\u4e0a\u9762\u7684\u793a\u4f8b\u4e2d\uff0c\u6211\u4eec\u9009\u62e9\u4e86Customers\u8868\u4e2d\u7684CustomerName\u5217\u548cOrders\u8868\u4e2d\u7684OrderID\u5217\u3002<\/p>\n<p>\u4f7f\u7528INNER JOIN\u5173\u952e\u5b57\u65f6\uff0c\u9700\u8981\u786e\u4fdd\u8fde\u63a5\u7684\u5217\u5728\u4e24\u4e2a\u8868\u4e2d\u5177\u6709\u76f8\u540c\u7684\u6570\u636e\u7c7b\u578b\u3002\u5426\u5219\uff0c\u8fde\u63a5\u53ef\u80fd\u4f1a\u5931\u8d25\u3002<\/p>\n<p>\u9664\u4e86INNER JOIN\u5173\u952e\u5b57\uff0cMySQL\u8fd8\u63d0\u4f9b\u4e86\u5176\u4ed6\u7c7b\u578b\u7684JOIN\u64cd\u4f5c\uff0c\u5982LEFT JOIN\u3001RIGHT JOIN\u548cFULL JOIN\u3002\u6bcf\u79cdJOIN\u64cd\u4f5c\u90fd\u6709\u4e0d\u540c\u7684\u7528\u9014\u548c\u8bed\u6cd5\u3002<\/p>\n<p>\u603b\u7ed3\uff1a<\/p>\n<p>\u5728MySQL\u4e2d\uff0c\u4f7f\u7528INNER JOIN\u5173\u952e\u5b57\u53ef\u4ee5\u8fd4\u56de\u4e24\u4e2a\u8868\u4e2d\u90fd\u6709\u5339\u914d\u503c\u7684\u884c\u3002\u5b83\u57fa\u4e8e\u4e24\u4e2a\u8868\u4e4b\u95f4\u7684\u5171\u540c\u5217\u503c\u8fdb\u884c\u5339\u914d\uff0c\u5e76\u8fd4\u56de\u8fd9\u4e9b\u8868\u4e2d\u90fd\u6709\u5339\u914d\u503c\u7684\u884c\u3002<\/p>\n<p>\u9999\u6e2f\u670d\u52a1\u5668\u9996\u9009\u540e\u6d6a\u4e91\uff1a<a href=\"https:\/\/idc.net\">https:\/\/idc.net<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL\u4f7f\u7528\u624b\u518c\uff1a\u4f7f\u7528INNER JOIN\u5173\u952e\u5b57\u8fd4\u56de\u4e24\u4e2a\u8868\u4e2d\u90fd\u6709\u5339\u914d\u503c\u7684\u884c MySQL\u4f7f\u7528\u624b\u518c\uff1a\u4f7f\u7528INNE [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[197851],"tags":[],"class_list":["post-217776","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/217776","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/comments?post=217776"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/217776\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=217776"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=217776"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=217776"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}