{"id":7134,"date":"2024-11-14T13:05:16","date_gmt":"2024-11-14T05:05:16","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7134\/"},"modified":"2024-11-14T13:05:16","modified_gmt":"2024-11-14T05:05:16","slug":"mybatis-plus-%e4%b8%ad%e5%a6%82%e4%bd%95%e5%ae%9e%e7%8e%b0%e5%a4%8d%e6%9d%82-sql-%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%8c%b9%e9%85%8d%e6%9f%a5%e8%af%a2%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7134\/","title":{"rendered":"MyBatis-Plus \u4e2d\u5982\u4f55\u5b9e\u73b0\u590d\u6742 SQL \u5b57\u7b26\u4e32\u5339\u914d\u67e5\u8be2\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173047035358902.jpg\" class=\"aligncenter\" title=\"MyBatis-Plus \u4e2d\u5982\u4f55\u5b9e\u73b0\u590d\u6742 SQL \u5b57\u7b26\u4e32\u5339\u914d\u67e5\u8be2\uff1f\u63d2\u56fe\" alt=\"MyBatis-Plus \u4e2d\u5982\u4f55\u5b9e\u73b0\u590d\u6742 SQL \u5b57\u7b26\u4e32\u5339\u914d\u67e5\u8be2\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong>sql \u5b57\u7b26\u4e32\u5339\u914d\u4e2d\u7684\u590d\u6742\u5339\u914d\u95ee\u9898<\/strong><\/p>\n<p>java \u5f00\u53d1\u4e2d\uff0c\u4f7f\u7528 mybatis-plus \u5904\u7406\u4e00\u4e2a\u590d\u6742 sql \u5b57\u7b26\u4e32\u5339\u914d\u67e5\u8be2\u65f6\u9047\u5230\u4e86\u96be\u9898\u3002\u95ee\u9898\u573a\u666f\u662f\u5339\u914d\u4e00\u4e2a\u53ef\u9009\u8bfe\u7a0b\u7684\u6761\u4ef6\u5b57\u6bb5 condition \u4e0e\u7528\u6237\u8f93\u5165\u7684 cond \u5b57\u6bb5\u3002\u5176\u4e2d condition \u4e3a\u9017\u53f7\u5206\u9694\u7684\u5fc5\u4fee\u8bfe\u7a0b\u5217\u8868\uff0c\u800c cond \u4e3a\u9017\u53f7\u5206\u9694\u7684\u7528\u6237\u5df2\u9009\u8bfe\u7a0b\u3002\u4efb\u52a1\u662f\u7f16\u5199\u4e00\u4e2a\u67e5\u8be2\uff0c\u53ea\u8981\u6761\u4ef6\u4e2d\u5305\u542b\u7528\u6237\u6240\u9009\u7684\u4efb\u610f\u4e00\u95e8\u8bfe\u7a0b\u5373\u53ef\u5339\u914d\u3002<\/p>\n<p><strong>sql \u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b sql \u8bed\u53e5\u6765\u5b9e\u73b0\uff1a<\/p>\n<pre>select *\nfrom college_course\nwhere find_in_set('\u8bed\u6587', condition) and find_in_set('\u97f3\u4e50', condition)<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6b64\u67e5\u8be2\u5c06\u67e5\u627e condition \u4e2d\u540c\u65f6\u5305\u542b\u8bed\u6587\u548c\u97f3\u4e50\u4e24\u95e8\u8bfe\u7a0b\u7684\u53ef\u9009\u8bfe\u7a0b\u3002<\/p>\n<p><strong>mybatis-plus \u96c6\u6210<\/strong><\/p>\n<p>\u8981\u5728 mybatis-plus \u4e2d\u4f7f\u7528\u6b64\u67e5\u8be2\uff0c\u53ef\u4ee5\u5728 querywrapper \u4e2d\u8bbe\u7f6e\u6761\u4ef6\uff1a<\/p>\n<pre>QueryWrapper&lt;CollegeCourse&gt; wrapper = new QueryWrapper&lt;&gt;();\nwrapper.eq(\"condition\", \"\u8bed\u6587,\u97f3\u4e50\");\nList&lt;CollegeCourse&gt; courses = collegeCourseMapper.selectList(wrapper);<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u6b64\u4ee3\u7801\u5c06\u68c0\u7d22\u540c\u65f6\u5305\u542b\u8bed\u6587\u548c\u97f3\u4e50\u8bfe\u7a0b\u7684\u53ef\u9009\u8bfe\u7a0b\u5217\u8868\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fMyBatis-Plus \u4e2d\u5982\u4f55\u5b9e\u73b0\u590d\u6742 SQL \u5b57\u7b26\u4e32\u5339\u914d\u67e5\u8be2\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>sql \u5b57\u7b26\u4e32\u5339\u914d\u4e2d\u7684\u590d\u6742\u5339\u914d\u95ee\u9898 java \u5f00\u53d1\u4e2d\uff0c\u4f7f\u7528 mybatis-plus \u5904\u7406\u4e00\u4e2a\u590d\u6742 sql \u5b57\u7b26\u4e32\u5339\u914d\u67e5\u8be2\u65f6\u9047\u5230\u4e86\u96be\u9898\u3002\u95ee\u9898\u573a\u666f\u662f\u5339\u914d\u4e00\u4e2a\u53ef\u9009\u8bfe\u7a0b\u7684\u6761\u4ef6\u5b57\u6bb5 condition \u4e0e\u7528\u6237\u8f93\u5165\u7684 cond \u5b57\u6bb5\u3002\u5176\u4e2d condition \u4e3a\u9017\u53f7\u5206\u9694\u7684\u5fc5\u4fee\u8bfe\u7a0b\u5217\u8868\uff0c\u800c cond \u4e3a\u9017\u53f7\u5206\u9694\u7684\u7528\u6237\u5df2\u9009\u8bfe\u7a0b\u3002\u4efb\u52a1\u662f\u7f16\u5199\u4e00\u4e2a\u67e5\u8be2\uff0c\u53ea\u8981\u6761\u4ef6\u4e2d\u5305\u542b\u7528\u6237\u6240\u9009\u7684\u4efb\u610f\u4e00\u95e8\u8bfe\u7a0b\u5373\u53ef\u5339\u914d\u3002 sql \u89e3\u51b3\u65b9\u6848 \u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b sql \u8bed\u53e5\u6765\u5b9e\u73b0\uff1a select * from college_course where find_in_set(&#8216;\u8bed\u6587&#8217;, condition) and find_in_set(&#8216;\u97f3\u4e50&#8217;, condition) \u767b\u5f55\u540e\u590d\u5236 \u6b64\u67e5\u8be2\u5c06\u67e5\u627e condition \u4e2d\u540c\u65f6\u5305\u542b\u8bed\u6587\u548c\u97f3\u4e50\u4e24\u95e8\u8bfe\u7a0b\u7684\u53ef\u9009\u8bfe\u7a0b\u3002 mybatis-plus \u96c6\u6210 \u8981\u5728 mybatis-plus \u4e2d\u4f7f\u7528\u6b64\u67e5\u8be2\uff0c\u53ef\u4ee5\u5728 querywrapper \u4e2d\u8bbe\u7f6e\u6761\u4ef6\uff1a QueryWrapper&lt;CollegeCourse&gt; wrapper = new QueryWrapper&lt;&gt;(); wrapper.eq(&#8220;condition&#8221;, &#8220;\u8bed\u6587,\u97f3\u4e50&#8221;); List&lt;CollegeCourse&gt; courses = collegeCourseMapper.selectList(wrapper); \u767b\u5f55\u540e\u590d\u5236 \u6b64\u4ee3\u7801\u5c06\u68c0\u7d22\u540c\u65f6\u5305\u542b\u8bed\u6587\u548c\u97f3\u4e50\u8bfe\u7a0b\u7684\u53ef\u9009\u8bfe\u7a0b\u5217\u8868\u3002 [&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-7134","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7134","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=7134"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7134\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7134"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7134"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7134"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}