{"id":44466,"date":"2024-12-01T11:22:54","date_gmt":"2024-12-01T03:22:54","guid":{"rendered":"https:\/\/fwq.ai\/blog\/44466\/"},"modified":"2024-12-01T11:22:54","modified_gmt":"2024-12-01T03:22:54","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-2","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/44466\/","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><b><\/b> <\/p>\n<h1>\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<\/h1>\n<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/www.17golang.com\/uploads\/20241026\/1729945482671cdf8a5f37a.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>mysql 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>\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>\u7406\u8bba\u8981\u638c\u63e1\uff0c\u5b9e\u64cd\u4e0d\u80fd\u843d\uff01\u4ee5\u4e0a\u5173\u4e8e\u300a\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\u300b\u7684\u8be6\u7ec6\u4ecb\u7ecd\uff0c\u5927\u5bb6\u90fd\u638c\u63e1\u4e86\u5427\uff01\u5982\u679c\u60f3\u8981\u7ee7\u7eed\u63d0\u5347\u81ea\u5df1\u7684\u80fd\u529b\uff0c\u90a3\u4e48\u5c31\u6765\u5173\u6ce8\u7c73\u4e91\u516c\u4f17\u53f7\u5427\uff01<\/p>\n<p> \u7248\u672c\u58f0\u660e \u672c\u6587\u8f6c\u8f7d\u4e8e\uff1aphp \u5982\u6709\u4fb5\u72af\uff0c\u8bf7\u8054\u7cfb \u5220\u9664 <\/p>\n<dl>\n<dt>\n <\/dt>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>\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 mysql 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;); \u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0cconcat() \u51fd\u6570\u5c06 [&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-44466","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/44466","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=44466"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/44466\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=44466"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=44466"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=44466"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}