{"id":6699,"date":"2024-11-14T10:17:38","date_gmt":"2024-11-14T02:17:38","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6699\/"},"modified":"2024-11-14T10:17:38","modified_gmt":"2024-11-14T02:17:38","slug":"%e5%a6%82%e4%bd%95%e4%bd%bf%e7%94%a8-concat-%e5%87%bd%e6%95%b0%e9%98%b2%e6%ad%a2-mysql-like-%e6%9f%a5%e8%af%a2%e4%b8%ad-%e5%92%8c-_-%e5%ad%97%e7%ac%a6%e5%af%bc%e8%87%b4%e7%9a%84%e5%ae%89%e5%85%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6699\/","title":{"rendered":"\u5982\u4f55\u4f7f\u7528 CONCAT() \u51fd\u6570\u9632\u6b62 MySQL LIKE \u67e5\u8be2\u4e2d % \u548c _ \u5b57\u7b26\u5bfc\u81f4\u7684\u5b89\u5168\u95ee\u9898\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/172974006335280.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u4f7f\u7528 CONCAT() \u51fd\u6570\u9632\u6b62 MySQL LIKE \u67e5\u8be2\u4e2d % \u548c _ \u5b57\u7b26\u5bfc\u81f4\u7684\u5b89\u5168\u95ee\u9898\uff1f\u63d2\u56fe\" alt=\"\u5982\u4f55\u4f7f\u7528 CONCAT() \u51fd\u6570\u9632\u6b62 MySQL LIKE \u67e5\u8be2\u4e2d % \u548c _ \u5b57\u7b26\u5bfc\u81f4\u7684\u5b89\u5168\u95ee\u9898\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong> like \u67e5\u8be2\u5b89\u5168\u8fc7\u6ee4 % \u548c _ \u5b57\u7b26<\/strong><\/p>\n<p>\u5728 mysql \u4e2d\u4f7f\u7528 like \u8bed\u53e5\u8fdb\u884c\u6a21\u7cca\u67e5\u8be2\u65f6\uff0c\u7ecf\u5e38\u9700\u8981\u5bf9 like \u8bed\u53e5\u540e\u9762\u7684\u53c2\u6570\u8fdb\u884c\u5b89\u5168\u8fc7\u6ee4\uff0c\u4ee5\u9632\u6b62 sql \u6ce8\u5165\u653b\u51fb\u3002\u5f53\u53c2\u6570\u5305\u542b % \u6216 _ \u5b57\u7b26\u65f6\uff0c\u53ef\u80fd\u5bfc\u81f4\u67e5\u8be2\u7ed3\u679c\u4e0d\u51c6\u786e\u6216\u51fa\u73b0\u5b89\u5168\u95ee\u9898\u3002<\/p>\n<p>\u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528 concat() \u51fd\u6570\u5bf9 like \u8bed\u53e5\u540e\u9762\u7684\u53c2\u6570\u8fdb\u884c\u8fc7\u6ee4\u3002concat() \u51fd\u6570\u53ef\u4ee5\u5c06\u591a\u4e2a\u5b57\u7b26\u4e32\u8fde\u63a5\u8d77\u6765\uff0c\u4ece\u800c\u5c06 % \u548c _ \u5b57\u7b26\u8f6c\u4e49\uff0c\u4f7f\u5176\u4e0d\u4f1a\u88ab mysql \u89e3\u91ca\u4e3a\u901a\u914d\u7b26\u3002<\/p>\n<p><strong>\u793a\u4f8b\uff1a<\/strong><\/p>\n<pre>SELECT * FROM table_name\nWHERE project LIKE CONCAT('%', '%$project%', '%');<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0cconcat() \u51fd\u6570\u5c06 %$project% \u5b57\u7b26\u4e32\u8fde\u63a5\u5230\u4e24\u4e2a % \u5b57\u7b26\uff0c\u6709\u6548\u5730\u8f6c\u4e49\u4e86 % \u548c _ \u5b57\u7b26\uff0c\u786e\u4fdd\u4e86\u67e5\u8be2\u7684\u5b89\u5168\u6027\u3002<\/p>\n<p>\u901a\u8fc7\u4f7f\u7528 concat() \u51fd\u6570\u8fc7\u6ee4 like \u8bed\u53e5\u540e\u9762\u7684\u53c2\u6570\uff0c\u53ef\u4ee5\u9632\u6b62 % \u548c _ \u5b57\u7b26\u5bfc\u81f4\u7684 sql \u6ce8\u5165\u653b\u51fb\uff0c\u5e76\u786e\u4fdd\u67e5\u8be2\u7ed3\u679c\u7684\u51c6\u786e\u6027\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u4f7f\u7528 CONCAT() \u51fd\u6570\u9632\u6b62 MySQL LIKE \u67e5\u8be2\u4e2d % \u548c _ \u5b57\u7b26\u5bfc\u81f4\u7684\u5b89\u5168\u95ee\u9898\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>like \u67e5\u8be2\u5b89\u5168\u8fc7\u6ee4 % \u548c _ \u5b57\u7b26 \u5728 mysql \u4e2d\u4f7f\u7528 like \u8bed\u53e5\u8fdb\u884c\u6a21\u7cca\u67e5\u8be2\u65f6\uff0c\u7ecf\u5e38\u9700\u8981\u5bf9 like \u8bed\u53e5\u540e\u9762\u7684\u53c2\u6570\u8fdb\u884c\u5b89\u5168\u8fc7\u6ee4\uff0c\u4ee5\u9632\u6b62 sql \u6ce8\u5165\u653b\u51fb\u3002\u5f53\u53c2\u6570\u5305\u542b % \u6216 _ \u5b57\u7b26\u65f6\uff0c\u53ef\u80fd\u5bfc\u81f4\u67e5\u8be2\u7ed3\u679c\u4e0d\u51c6\u786e\u6216\u51fa\u73b0\u5b89\u5168\u95ee\u9898\u3002 \u4e3a\u4e86\u89e3\u51b3\u8fd9\u4e2a\u95ee\u9898\uff0c\u53ef\u4ee5\u4f7f\u7528 concat() \u51fd\u6570\u5bf9 like \u8bed\u53e5\u540e\u9762\u7684\u53c2\u6570\u8fdb\u884c\u8fc7\u6ee4\u3002concat() \u51fd\u6570\u53ef\u4ee5\u5c06\u591a\u4e2a\u5b57\u7b26\u4e32\u8fde\u63a5\u8d77\u6765\uff0c\u4ece\u800c\u5c06 % \u548c _ \u5b57\u7b26\u8f6c\u4e49\uff0c\u4f7f\u5176\u4e0d\u4f1a\u88ab mysql \u89e3\u91ca\u4e3a\u901a\u914d\u7b26\u3002 \u793a\u4f8b\uff1a SELECT * FROM table_name WHERE project LIKE CONCAT(&#8216;%&#8217;, &#8216;%$project%&#8217;, &#8216;%&#8217;); \u767b\u5f55\u540e\u590d\u5236 \u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0cconcat() \u51fd\u6570\u5c06 %$project% \u5b57\u7b26\u4e32\u8fde\u63a5\u5230\u4e24\u4e2a % \u5b57\u7b26\uff0c\u6709\u6548\u5730\u8f6c\u4e49\u4e86 % \u548c _ \u5b57\u7b26\uff0c\u786e\u4fdd\u4e86\u67e5\u8be2\u7684\u5b89\u5168\u6027\u3002 \u901a\u8fc7\u4f7f\u7528 concat() [&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-6699","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6699","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=6699"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6699\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6699"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6699"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6699"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}