{"id":217810,"date":"2023-12-23T00:38:25","date_gmt":"2023-12-22T16:38:25","guid":{"rendered":"https:\/\/www.idc.net\/help\/217810\/"},"modified":"2023-12-23T00:38:25","modified_gmt":"2023-12-22T16:38:25","slug":"mysql%e4%bd%bf%e7%94%a8%e6%89%8b%e5%86%8c%ef%bc%9a%e4%bd%bf%e7%94%a8in%e6%93%8d%e4%bd%9c%e7%ac%a6%e6%8c%87%e5%ae%9a%e6%9f%90%e5%88%97%e7%9a%84%e5%a4%9a%e4%b8%aa%e5%8f%af%e8%83%bd%e5%80%bc","status":"publish","type":"post","link":"https:\/\/idc.net\/help\/217810\/","title":{"rendered":"MySQL\u4f7f\u7528\u624b\u518c\uff1a\u4f7f\u7528IN\u64cd\u4f5c\u7b26\u6307\u5b9a\u67d0\u5217\u7684\u591a\u4e2a\u53ef\u80fd\u503c"},"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%a8in%e6%93%8d%e4%bd%9c%e7%ac%a6%e6%8c%87%e5%ae%9a%e6%9f%90%e5%88%97%e7%9a%84%e5%a4%9a%e4%b8%aa%e5%8f%af%e8%83%bd%e5%80%bc-lZLIZMVpYI\">MySQL\u4f7f\u7528\u624b\u518c\uff1a\u4f7f\u7528IN\u64cd\u4f5c\u7b26\u6307\u5b9a\u67d0\u5217\u7684\u591a\u4e2a\u53ef\u80fd\u503c<\/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%a8in%e6%93%8d%e4%bd%9c%e7%ac%a6%e6%8c%87%e5%ae%9a%e6%9f%90%e5%88%97%e7%9a%84%e5%a4%9a%e4%b8%aa%e5%8f%af%e8%83%bd%e5%80%bc-lZLIZMVpYI\">MySQL\u4f7f\u7528\u624b\u518c\uff1a\u4f7f\u7528IN\u64cd\u4f5c\u7b26\u6307\u5b9a\u67d0\u5217\u7684\u591a\u4e2a\u53ef\u80fd\u503c<\/h1>\n<p>\u5728MySQL\u4e2d\uff0cIN\u64cd\u4f5c\u7b26\u7528\u4e8e\u6307\u5b9a\u67d0\u5217\u7684\u591a\u4e2a\u53ef\u80fd\u503c\u3002\u5b83\u5141\u8bb8\u6211\u4eec\u5728\u67e5\u8be2\u4e2d\u6307\u5b9a\u4e00\u4e2a\u5217\uff0c\u5e76\u4e14\u53ef\u4ee5\u5339\u914d\u591a\u4e2a\u53ef\u80fd\u7684\u503c\u3002\u8fd9\u5728\u5904\u7406\u5927\u91cf\u6570\u636e\u65f6\u975e\u5e38\u6709\u7528\uff0c\u53ef\u4ee5\u7b80\u5316\u67e5\u8be2\u8bed\u53e5\u5e76\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\u3002<\/p>\n<h2 id=\"%e4%bd%bf%e7%94%a8in%e6%93%8d%e4%bd%9c%e7%ac%a6%e7%9a%84%e8%af%ad%e6%b3%95-lZLIZMVpYI\">\u4f7f\u7528IN\u64cd\u4f5c\u7b26\u7684\u8bed\u6cd5<\/h2>\n<p>\u4f7f\u7528IN\u64cd\u4f5c\u7b26\u7684\u8bed\u6cd5\u5982\u4e0b\uff1a<\/p>\n<pre><code>SELECT column_name(s)\nFROM table_name\nWHERE column_name IN (value1, value2, ...);\n<\/code><\/pre>\n<p>\u5728\u4e0a\u9762\u7684\u8bed\u6cd5\u4e2d\uff0ccolumn_name\u662f\u8981\u5339\u914d\u7684\u5217\u540d\uff0ctable_name\u662f\u8981\u67e5\u8be2\u7684\u8868\u540d\uff0cvalue1\u3001value2\u7b49\u662f\u8981\u5339\u914d\u7684\u503c\u3002<\/p>\n<h2 id=\"%e4%bd%bf%e7%94%a8in%e6%93%8d%e4%bd%9c%e7%ac%a6%e7%9a%84%e7%a4%ba%e4%be%8b-lZLIZMVpYI\">\u4f7f\u7528IN\u64cd\u4f5c\u7b26\u7684\u793a\u4f8b<\/h2>\n<p>\u5047\u8bbe\u6211\u4eec\u6709\u4e00\u4e2a\u540d\u4e3a\"customers\"\u7684\u8868\uff0c\u5176\u4e2d\u5305\u542b\u4e86\u5ba2\u6237\u7684\u4fe1\u606f\uff0c\u5305\u62ec\u59d3\u540d\u3001\u57ce\u5e02\u548c\u56fd\u5bb6\u3002\u6211\u4eec\u60f3\u8981\u67e5\u8be2\u5c45\u4f4f\u5728\u4e2d\u56fd\u6216\u7f8e\u56fd\u7684\u5ba2\u6237\u3002\u53ef\u4ee5\u4f7f\u7528IN\u64cd\u4f5c\u7b26\u6765\u5b9e\u73b0\uff1a<\/p>\n<pre><code>SELECT *\nFROM customers\nWHERE country IN ('\u4e2d\u56fd', '\u7f8e\u56fd');\n<\/code><\/pre>\n<p>\u4e0a\u9762\u7684\u67e5\u8be2\u5c06\u8fd4\u56de\u6240\u6709\u5c45\u4f4f\u5728\u4e2d\u56fd\u6216\u7f8e\u56fd\u7684\u5ba2\u6237\u7684\u4fe1\u606f\u3002<\/p>\n<h2 id=\"%e4%bd%bf%e7%94%a8in%e6%93%8d%e4%bd%9c%e7%ac%a6%e7%9a%84%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a1%b9-lZLIZMVpYI\">\u4f7f\u7528IN\u64cd\u4f5c\u7b26\u7684\u6ce8\u610f\u4e8b\u9879<\/h2>\n<p>\u5728\u4f7f\u7528IN\u64cd\u4f5c\u7b26\u65f6\uff0c\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u51e0\u70b9\uff1a<\/p>\n<ul>\n<li>IN\u64cd\u4f5c\u7b26\u53ef\u4ee5\u4e0e\u5176\u4ed6\u64cd\u4f5c\u7b26\uff08\u5982AND\u3001OR\uff09\u4e00\u8d77\u4f7f\u7528\uff0c\u4ee5\u6784\u5efa\u66f4\u590d\u6742\u7684\u67e5\u8be2\u6761\u4ef6\u3002<\/li>\n<li>IN\u64cd\u4f5c\u7b26\u53ef\u4ee5\u7528\u4e8e\u4efb\u4f55\u6570\u636e\u7c7b\u578b\u7684\u5217\uff0c\u5305\u62ec\u6570\u5b57\u3001\u5b57\u7b26\u4e32\u7b49\u3002<\/li>\n<li>IN\u64cd\u4f5c\u7b26\u53ef\u4ee5\u7528\u4e8e\u5b50\u67e5\u8be2\uff0c\u4ee5\u5b9e\u73b0\u66f4\u7075\u6d3b\u7684\u67e5\u8be2\u3002<\/li>\n<\/ul>\n<h2 id=\"%e6%80%bb%e7%bb%93-lZLIZMVpYI\">\u603b\u7ed3<\/h2>\n<p>\u901a\u8fc7\u4f7f\u7528IN\u64cd\u4f5c\u7b26\uff0c\u6211\u4eec\u53ef\u4ee5\u6307\u5b9a\u67d0\u5217\u7684\u591a\u4e2a\u53ef\u80fd\u503c\uff0c\u4ece\u800c\u7b80\u5316\u67e5\u8be2\u8bed\u53e5\u5e76\u63d0\u9ad8\u67e5\u8be2\u6548\u7387\u3002\u5728\u5904\u7406\u5927\u91cf\u6570\u636e\u65f6\uff0c\u8fd9\u662f\u975e\u5e38\u6709\u7528\u7684\u3002\u5982\u679c\u60a8\u60f3\u8981\u4e86\u89e3\u66f4\u591a\u5173\u4e8eMySQL\u7684\u4f7f\u7528\u624b\u518c\uff0c\u8bf7\u8bbf\u95ee\u6211\u4eec\u7684\u5b98\u7f51\uff1a<a href=\"https:\/\/idc.net\">https:\/\/idc.net<\/a>\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>MySQL\u4f7f\u7528\u624b\u518c\uff1a\u4f7f\u7528IN\u64cd\u4f5c\u7b26\u6307\u5b9a\u67d0\u5217\u7684\u591a\u4e2a\u53ef\u80fd\u503c MySQL\u4f7f\u7528\u624b\u518c\uff1a\u4f7f\u7528IN\u64cd\u4f5c\u7b26\u6307\u5b9a\u67d0\u5217\u7684\u591a\u4e2a\u53ef\u80fd\u503c [&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-217810","post","type-post","status-publish","format-standard","hentry","category-php"],"_links":{"self":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/217810","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=217810"}],"version-history":[{"count":0,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/posts\/217810\/revisions"}],"wp:attachment":[{"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/media?parent=217810"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/categories?post=217810"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idc.net\/help\/wp-json\/wp\/v2\/tags?post=217810"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}