{"id":7852,"date":"2024-11-14T15:00:07","date_gmt":"2024-11-14T07:00:07","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7852\/"},"modified":"2024-11-14T15:00:07","modified_gmt":"2024-11-14T07:00:07","slug":"%e5%9c%a8-java-%e4%bb%a3%e7%a0%81%e5%92%8c-mysql-where-%e5%ad%90%e5%8f%a5%e4%b8%ad%ef%bc%8c%e5%a6%82%e4%bd%95%e6%9b%b4%e6%9c%89%e6%95%88%e5%9c%b0%e6%89%a7%e8%a1%8c%e8%bf%90%e7%ae%97%e6%93%8d%e4%bd%9c","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7852\/","title":{"rendered":"\u5728 Java \u4ee3\u7801\u548c MySQL WHERE \u5b50\u53e5\u4e2d\uff0c\u5982\u4f55\u66f4\u6709\u6548\u5730\u6267\u884c\u8fd0\u7b97\u64cd\u4f5c\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173130036681768.jpg\" class=\"aligncenter\" title=\"\u5728 Java \u4ee3\u7801\u548c MySQL WHERE \u5b50\u53e5\u4e2d\uff0c\u5982\u4f55\u66f4\u6709\u6548\u5730\u6267\u884c\u8fd0\u7b97\u64cd\u4f5c\uff1f\u63d2\u56fe\" alt=\"\u5728 Java \u4ee3\u7801\u548c MySQL WHERE \u5b50\u53e5\u4e2d\uff0c\u5982\u4f55\u66f4\u6709\u6548\u5730\u6267\u884c\u8fd0\u7b97\u64cd\u4f5c\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 java \u4ee3\u7801\u548c  where \u5b50\u53e5\u4e2d\u6267\u884c\u8fd0\u7b97\u64cd\u4f5c\uff1f<\/strong><\/p>\n<p>\u5728\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u4e2d\uff0c\u7ecf\u5e38\u9700\u8981\u5bf9\u4ece\u6570\u636e\u5e93\u83b7\u53d6\u7684\u6570\u636e\u8fdb\u884c\u8fd0\u7b97\u3002\u4f8b\u5982\uff0c\u67e5\u8be2\u7528\u6237\u5e74\u9f84\u5e76\u5bf9\u5176\u8fdb\u884c\u589e\u4e00\u64cd\u4f5c\u3002\u6b64\u65f6\uff0c\u8fd0\u7b97\u64cd\u4f5c\u53ef\u4ee5\u653e\u5728 java \u4ee3\u7801\u6216 mysql where \u5b50\u53e5\u4e2d\u6267\u884c\u3002<\/p>\n<p>\u6839\u636e mysql \u5b98\u65b9\u6587\u6863\uff0c\u5728 where \u5b50\u53e5\u4e2d\u4f7f\u7528\u8868\u8fbe\u5f0f\u4f1a\u9020\u6210\u7d22\u5f15\u5931\u6548\u3002\u56e0\u6b64\uff0c\u5f53\u88ab\u67e5\u8be2\u7684\u5217\u5b58\u5728\u7d22\u5f15\u65f6\uff0c\u5efa\u8bae\u5c06\u8fd0\u7b97\u64cd\u4f5c\u653e\u5728 java \u4ee3\u7801\u4e2d\u6267\u884c\u3002<\/p>\n<p><strong>\u653e\u7f6e\u4e8e java \u4ee3\u7801\u7684\u597d\u5904\uff1a<\/strong><\/p>\n<p><span>\u7acb\u5373\u5b66\u4e60<\/span>\u201c\u201d\uff1b<\/p>\n<ul>\n<li>\u4fdd\u6301\u7d22\u5f15\u6709\u6548\u6027\uff0c\u63d0\u5347\u67e5\u8be2\u6548\u7387<\/li>\n<li>\u4ee3\u7801\u6e05\u6670\u660e\u4e86\uff0c\u8fd0\u7b97\u8fc7\u7a0b\u4e00\u76ee\u4e86\u7136<\/li>\n<li>\u907f\u514d sql \u8bed\u53e5\u8fc7\u4e8e\u590d\u6742\uff0c\u63d0\u9ad8\u53ef\u8bfb\u6027<\/li>\n<\/ul>\n<p><strong>mybatis \u793a\u4f8b\uff1a<\/strong><\/p>\n<p>\u4f7f\u7528 mybatis \u65f6\uff0c\u53ef\u5728\u4ee5\u4e0b\u4f4d\u7f6e\u8fdb\u884c\u8fd0\u7b97\u64cd\u4f5c\uff1a<\/p>\n<pre>\/\/ Java \u4ee3\u7801\u4e2d\u6267\u884c\u8fd0\u7b97\nList&lt;Integer&gt; ages = new ArrayList&lt;&gt;();\nfor (int age : agesDb) {\n    ages.add(age + 1);\n}\n\n\/\/ Mybatis \u4e2d\u7684 in \u64cd\u4f5c\uff1a\nSELECT id, age\nFROM users\nWHERE age IN (#{ages})<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u7ed3\u8bba\uff1a<\/strong><\/p>\n<p>\u5f53\u88ab\u67e5\u8be2\u7684\u5217\u5b58\u5728\u7d22\u5f15\u65f6\uff0c\u5efa\u8bae\u5c06\u8fd0\u7b97\u64cd\u4f5c\u653e\u5728 java \u4ee3\u7801\u4e2d\u6267\u884c\u3002\u8fd9\u6837\u505a\u4e0d\u4ec5\u53ef\u4ee5\u4fdd\u6301\u7d22\u5f15\u6709\u6548\u6027\uff0c\u8fd8\u80fd\u63d0\u9ad8\u4ee3\u7801\u7684\u53ef\u8bfb\u6027\u548c\u53ef\u7ef4\u62a4\u6027\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5728 Java \u4ee3\u7801\u548c MySQL WHERE \u5b50\u53e5\u4e2d\uff0c\u5982\u4f55\u66f4\u6709\u6548\u5730\u6267\u884c\u8fd0\u7b97\u64cd\u4f5c\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5728 java \u4ee3\u7801\u548c where \u5b50\u53e5\u4e2d\u6267\u884c\u8fd0\u7b97\u64cd\u4f5c\uff1f \u5728\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u4e2d\uff0c\u7ecf\u5e38\u9700\u8981\u5bf9\u4ece\u6570\u636e\u5e93\u83b7\u53d6\u7684\u6570\u636e\u8fdb\u884c\u8fd0\u7b97\u3002\u4f8b\u5982\uff0c\u67e5\u8be2\u7528\u6237\u5e74\u9f84\u5e76\u5bf9\u5176\u8fdb\u884c\u589e\u4e00\u64cd\u4f5c\u3002\u6b64\u65f6\uff0c\u8fd0\u7b97\u64cd\u4f5c\u53ef\u4ee5\u653e\u5728 java \u4ee3\u7801\u6216 mysql where \u5b50\u53e5\u4e2d\u6267\u884c\u3002 \u6839\u636e mysql \u5b98\u65b9\u6587\u6863\uff0c\u5728 where \u5b50\u53e5\u4e2d\u4f7f\u7528\u8868\u8fbe\u5f0f\u4f1a\u9020\u6210\u7d22\u5f15\u5931\u6548\u3002\u56e0\u6b64\uff0c\u5f53\u88ab\u67e5\u8be2\u7684\u5217\u5b58\u5728\u7d22\u5f15\u65f6\uff0c\u5efa\u8bae\u5c06\u8fd0\u7b97\u64cd\u4f5c\u653e\u5728 java \u4ee3\u7801\u4e2d\u6267\u884c\u3002 \u653e\u7f6e\u4e8e java \u4ee3\u7801\u7684\u597d\u5904\uff1a \u7acb\u5373\u5b66\u4e60\u201c\u201d\uff1b \u4fdd\u6301\u7d22\u5f15\u6709\u6548\u6027\uff0c\u63d0\u5347\u67e5\u8be2\u6548\u7387 \u4ee3\u7801\u6e05\u6670\u660e\u4e86\uff0c\u8fd0\u7b97\u8fc7\u7a0b\u4e00\u76ee\u4e86\u7136 \u907f\u514d sql \u8bed\u53e5\u8fc7\u4e8e\u590d\u6742\uff0c\u63d0\u9ad8\u53ef\u8bfb\u6027 mybatis \u793a\u4f8b\uff1a \u4f7f\u7528 mybatis \u65f6\uff0c\u53ef\u5728\u4ee5\u4e0b\u4f4d\u7f6e\u8fdb\u884c\u8fd0\u7b97\u64cd\u4f5c\uff1a \/\/ Java \u4ee3\u7801\u4e2d\u6267\u884c\u8fd0\u7b97 List&lt;Integer&gt; ages = new ArrayList&lt;&gt;(); for (int age : agesDb) { ages.add(age + 1); } \/\/ Mybatis \u4e2d\u7684 in \u64cd\u4f5c\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-7852","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7852","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=7852"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7852\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7852"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7852"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7852"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}