{"id":7522,"date":"2024-11-14T13:54:25","date_gmt":"2024-11-14T05:54:25","guid":{"rendered":"https:\/\/fwq.ai\/blog\/7522\/"},"modified":"2024-11-14T13:54:25","modified_gmt":"2024-11-14T05:54:25","slug":"mysql-like-%e5%8c%b9%e9%85%8d%e4%b8%ba%e4%bb%80%e4%b9%88%e4%bc%9a%e5%87%ba%e7%8e%b0%e6%84%8f%e5%a4%96%e7%bb%93%e6%9e%9c%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/7522\/","title":{"rendered":"MySQL LIKE \u5339\u914d\u4e3a\u4ec0\u4e48\u4f1a\u51fa\u73b0\u610f\u5916\u7ed3\u679c\uff1f"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/001\/246\/273\/173095776566836.jpg\" class=\"aligncenter\" title=\"MySQL LIKE \u5339\u914d\u4e3a\u4ec0\u4e48\u4f1a\u51fa\u73b0\u610f\u5916\u7ed3\u679c\uff1f\u63d2\u56fe\" alt=\"MySQL LIKE \u5339\u914d\u4e3a\u4ec0\u4e48\u4f1a\u51fa\u73b0\u610f\u5916\u7ed3\u679c\uff1f\u63d2\u56fe\" \/><\/p>\n<p><strong> \u4e2d like \u5339\u914d\u5dee\u5f02<\/strong><\/p>\n<p>mysql \u4e2d like \u64cd\u4f5c\u7b26\u7528\u4e8epattern\u5339\u914d\uff0c\u4f46\u5176\u5339\u914d\u884c\u4e3a\u4e0e\u9884\u671f\u53ef\u80fd\u5b58\u5728\u5dee\u5f02\u3002<\/p>\n<p><strong>\u95ee\u9898\u73b0\u8c61<\/strong><\/p>\n<p>\u5728\u4e0b\u8ff0 sql \u8bed\u53e5\u4e2d\uff1a<\/p>\n<pre>select * from user where user.`name` like '%tina rodriguez%';<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5047\u5b9a user \u8868\u4e2d\u5b58\u5728\u8bb0\u5f55\uff1a<\/p>\n<table>\n<thead>\n<tr>\n<th>id<\/th>\n<th>name<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>1<\/td>\n<td>rodriguez<\/td>\n<\/tr>\n<tr>\n<td>2<\/td>\n<td>tina rodriguez<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>\u6309\u7167\u901a\u5e38\u7406\u89e3\uff0c%tina rodriguez% \u6a21\u5f0f\u5e94\u8be5\u4ec5\u5339\u914d name \u5217\u5305\u542b &#8220;tina rodriguez&#8221; \u7684\u8bb0\u5f55\u3002\u7136\u800c\uff0c\u67e5\u8be2\u7ed3\u679c\u610f\u5916\u5730\u5305\u62ec\u4e86 name \u5217\u4ec5\u5305\u542b &#8220;rodriguez&#8221; \u7684\u8bb0\u5f55\u3002<\/p>\n<p><strong>\u539f\u56e0\u5206\u6790<\/strong><\/p>\n<p>\u9020\u6210\u5dee\u5f02\u7684\u539f\u56e0\u662f like \u64cd\u4f5c\u7b26\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002\u8fd9\u610f\u5473\u7740 pattern \u4e2d\u7684 &#8220;t&#8221; \u548c &#8220;r&#8221; \u4e0e &#8220;t&#8221; \u548c &#8220;r&#8221; \u7b49\u6548\u3002\u56e0\u6b64\uff0c&#8221;rodriguez&#8221; \u53ef\u4ee5\u5339\u914d\u6a21\u5f0f\u4e2d\u7684 &#8220;tina rodriguez&#8221;\u3002<\/p>\n<p><strong>\u89e3\u51b3\u65b9\u6848<\/strong><\/p>\n<p>\u4e3a\u4e86\u7cbe\u786e\u5339\u914d\u7279\u5b9a\u5b57\u7b26\u4e32\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u65b9\u5f0f\uff1a<\/p>\n<pre>like 'Tina Rodriguez%'<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u8fd9\u6837\uff0c\u67e5\u8be2\u624d\u4f1a\u5339\u914d name \u5217\u660e\u786e\u5305\u542b &#8220;tina rodriguez&#8221; \u7684\u8bb0\u5f55\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fMySQL LIKE \u5339\u914d\u4e3a\u4ec0\u4e48\u4f1a\u51fa\u73b0\u610f\u5916\u7ed3\u679c\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>\u4e2d like \u5339\u914d\u5dee\u5f02 mysql \u4e2d like \u64cd\u4f5c\u7b26\u7528\u4e8epattern\u5339\u914d\uff0c\u4f46\u5176\u5339\u914d\u884c\u4e3a\u4e0e\u9884\u671f\u53ef\u80fd\u5b58\u5728\u5dee\u5f02\u3002 \u95ee\u9898\u73b0\u8c61 \u5728\u4e0b\u8ff0 sql \u8bed\u53e5\u4e2d\uff1a select * from user where user.`name` like &#8216;%tina rodriguez%&#8217;; \u767b\u5f55\u540e\u590d\u5236 \u5047\u5b9a user \u8868\u4e2d\u5b58\u5728\u8bb0\u5f55\uff1a id name 1 rodriguez 2 tina rodriguez \u6309\u7167\u901a\u5e38\u7406\u89e3\uff0c%tina rodriguez% \u6a21\u5f0f\u5e94\u8be5\u4ec5\u5339\u914d name \u5217\u5305\u542b &#8220;tina rodriguez&#8221; \u7684\u8bb0\u5f55\u3002\u7136\u800c\uff0c\u67e5\u8be2\u7ed3\u679c\u610f\u5916\u5730\u5305\u62ec\u4e86 name \u5217\u4ec5\u5305\u542b &#8220;rodriguez&#8221; \u7684\u8bb0\u5f55\u3002 \u539f\u56e0\u5206\u6790 \u9020\u6210\u5dee\u5f02\u7684\u539f\u56e0\u662f like \u64cd\u4f5c\u7b26\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002\u8fd9\u610f\u5473\u7740 pattern \u4e2d\u7684 &#8220;t&#8221; \u548c &#8220;r&#8221; \u4e0e &#8220;t&#8221; \u548c [&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-7522","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7522","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=7522"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/7522\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=7522"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=7522"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=7522"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}