{"id":27469,"date":"2024-11-24T16:51:46","date_gmt":"2024-11-24T08:51:46","guid":{"rendered":"https:\/\/fwq.ai\/blog\/27469\/"},"modified":"2024-11-24T16:51:46","modified_gmt":"2024-11-24T08:51:46","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-mybatis-xml-%e5%9c%a8%e5%8f%98%e9%87%8f%e5%80%bc%e7%9a%84%e5%9f%ba%e7%a1%80%e4%b8%8a%e6%89%a7%e8%a1%8c%e5%8a%a8%e6%80%81-sql%ef%bc%9f-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/27469\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 MyBatis XML \u5728\u53d8\u91cf\u503c\u7684\u57fa\u7840\u4e0a\u6267\u884c\u52a8\u6001 SQL\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173124883977124.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 MyBatis XML \u5728\u53d8\u91cf\u503c\u7684\u57fa\u7840\u4e0a\u6267\u884c\u52a8\u6001 SQL\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 MyBatis XML \u5728\u53d8\u91cf\u503c\u7684\u57fa\u7840\u4e0a\u6267\u884c\u52a8\u6001 SQL\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5728 mybatis xml \u4e2d\u57fa\u4e8e\u53d8\u91cf\u503c\u6267\u884c\u52a8\u6001 sql<\/strong><\/p>\n<p>mybatis \u63d0\u4f9b\u4e86\u591a\u79cd\u65b9\u6cd5\u6765\u6839\u636e\u53d8\u91cf\u503c\u52a8\u6001\u6267\u884c sql \u8bed\u53e5\u3002<\/p>\n<p><strong>\u4f7f\u7528\u6570\u636e\u5e93\u5382\u5546\u6807\u8bc6<\/strong><\/p>\n<p>mybatis \u5177\u6709\u5185\u7f6e\u7684\u6570\u636e\u5e93\u5382\u5546\u6807\u8bc6\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u5b83\u6765\u6307\u5b9a\u4e0d\u540c\u7684 sql \u8bed\u53e5\uff0c\u5177\u4f53\u53d6\u51b3\u4e8e\u6240\u4f7f\u7528\u7684\u6570\u636e\u5e93\u7c7b\u578b\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>&lt;select id=\"selectone\" databaseid=\"mysql\"&gt;\n    ...\n&lt;\/select&gt;\n&lt;select id=\"selectone\" databaseid=\"dameng\"&gt;\n    ...\n&lt;\/select&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u4f7f\u7528 if \u6807\u7b7e<\/strong><\/p>\n<p>\u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 if \u6807\u7b7e\u6839\u636e\u53d8\u91cf\u503c\u6709\u6761\u4ef6\u5730\u6267\u884c sql \u8bed\u53e5\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>&lt;select id=\"selectone\"&gt;\n    &lt;if test=\"databasetype == 1\"&gt;\n        ...\n    &lt;\/if&gt;\n    &lt;if test=\"databasetype == 2\"&gt;\n        ...\n    &lt;\/if&gt;\n&lt;\/select&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u4f7f\u7528 choose \u6807\u7b7e<\/strong><\/p>\n<p>choose \u6807\u7b7e\u5141\u8bb8\u60a8\u6839\u636e\u591a\u4e2a\u6761\u4ef6\u6267\u884c\u4e0d\u540c\u7684 sql \u8bed\u53e5\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>&lt;select id=\"selectOne\"&gt;\n    &lt;choose&gt;\n        &lt;when test=\"databaseType == 1\"&gt;\n            ...\n        &lt;\/when&gt;\n        &lt;when test=\"databaseType == 2\"&gt;\n            ...\n        &lt;\/when&gt;\n        &lt;otherwise&gt;\n            ...\n        &lt;\/otherwise&gt;\n    &lt;\/choose&gt;\n&lt;\/select&gt;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 MyBatis XML \u5728\u53d8\u91cf\u503c\u7684\u57fa\u7840\u4e0a\u6267\u884c\u52a8\u6001 SQL\uff1f\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5982\u4f55\u5728 mybatis xml \u4e2d\u57fa\u4e8e\u53d8\u91cf\u503c\u6267\u884c\u52a8\u6001 sql mybatis \u63d0\u4f9b\u4e86\u591a\u79cd\u65b9\u6cd5\u6765\u6839\u636e\u53d8\u91cf\u503c\u52a8\u6001\u6267\u884c sql \u8bed\u53e5\u3002 \u4f7f\u7528\u6570\u636e\u5e93\u5382\u5546\u6807\u8bc6 mybatis \u5177\u6709\u5185\u7f6e\u7684\u6570\u636e\u5e93\u5382\u5546\u6807\u8bc6\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528\u5b83\u6765\u6307\u5b9a\u4e0d\u540c\u7684 sql \u8bed\u53e5\uff0c\u5177\u4f53\u53d6\u51b3\u4e8e\u6240\u4f7f\u7528\u7684\u6570\u636e\u5e93\u7c7b\u578b\u3002\u4f8b\u5982\uff1a &lt;select id=&#8221;selectone&#8221; databaseid=&#8221;mysql&#8221;&gt; &#8230; &lt;\/select&gt; &lt;select id=&#8221;selectone&#8221; databaseid=&#8221;dameng&#8221;&gt; &#8230; &lt;\/select&gt; \u767b\u5f55\u540e\u590d\u5236 \u4f7f\u7528 if \u6807\u7b7e \u60a8\u8fd8\u53ef\u4ee5\u4f7f\u7528 if \u6807\u7b7e\u6839\u636e\u53d8\u91cf\u503c\u6709\u6761\u4ef6\u5730\u6267\u884c sql \u8bed\u53e5\u3002\u4f8b\u5982\uff1a &lt;select id=&#8221;selectone&#8221;&gt; &lt;if test=&#8221;databasetype == 1&#8243;&gt; &#8230; &lt;\/if&gt; &lt;if test=&#8221;databasetype == 2&#8243;&gt; &#8230; &lt;\/if&gt; &lt;\/select&gt; \u767b\u5f55\u540e\u590d\u5236 \u4f7f\u7528 choose \u6807\u7b7e choose \u6807\u7b7e\u5141\u8bb8\u60a8\u6839\u636e\u591a\u4e2a\u6761\u4ef6\u6267\u884c\u4e0d\u540c\u7684 sql [&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-27469","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27469","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=27469"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/27469\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=27469"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=27469"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=27469"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}