{"id":6376,"date":"2024-11-14T08:29:59","date_gmt":"2024-11-14T00:29:59","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6376\/"},"modified":"2024-11-14T08:29:59","modified_gmt":"2024-11-14T00:29:59","slug":"mysql%e9%80%9a%e9%85%8d%e7%ac%a6%e7%9a%84%e4%bd%bf%e7%94%a8","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6376\/","title":{"rendered":"mysql\u901a\u914d\u7b26\u7684\u4f7f\u7528"},"content":{"rendered":"<blockquote><p>\n  mysql \u63d0\u4f9b\u4e24\u79cd\u901a\u914d\u7b26\uff1a\u767e\u5206\u53f7\u7528\u4e8e\u5339\u914d\u96f6\u4e2a\u6216\u66f4\u591a\u5b57\u7b26\uff0c\u4e0b\u5212\u7ebf\u7528\u4e8e\u5339\u914d\u5355\u4e2a\u5b57\u7b26\u3002\u4f7f\u7528\u901a\u914d\u7b26\u7684\u793a\u4f8b\u5305\u62ec\uff1a\u767e\u5206\u53f7\u901a\u914d\u7b26\uff1a&#8221;abc%&#8221; \u5339\u914d\u4ee5 &#8220;abc&#8221; \u5f00\u5934\u7684\u6240\u6709\u5b57\u7b26\u4e32\u3002&#8221;%abc&#8221; \u5339\u914d\u4ee5 &#8220;abc&#8221; \u7ed3\u5c3e\u7684\u6240\u6709\u5b57\u7b26\u4e32\u3002&#8221;%abc%&#8221; \u5339\u914d\u5305\u542b &#8220;abc&#8221; \u7684\u6240\u6709\u5b57\u7b26\u4e32\u3002\u4e0b\u5212\u7ebf\u901a\u914d\u7b26\uff1a&#8221;a_c&#8221; \u5339\u914d &#8220;abc&#8221; \u548c &#8220;acc&#8221;\u3002&#8221;_bc&#8221; \u5339\u914d &#8220;dbc&#8221; \u548c &#8220;ebc&#8221;\u3002&#8221;%_c%&#8221; \u5339\u914d\u5305\u542b\u5355\u4e2a\u5b57\u7b26\u4e14\u4ee5 &#8220;c&#8221; \u7ed3\u5c3e\u7684\u6240\u6709\u5b57\u7b26\u4e32\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202408\/01\/2024080106133417845.jpg\" class=\"aligncenter\" title=\"mysql\u901a\u914d\u7b26\u7684\u4f7f\u7528\u63d2\u56fe\" alt=\"mysql\u901a\u914d\u7b26\u7684\u4f7f\u7528\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u901a\u914d\u7b26\u7684\u4f7f\u7528<\/strong><\/p>\n<p><strong>\u4ec0\u4e48\u662f\u901a\u914d\u7b26\uff1f<\/strong><\/p>\n<p>\u901a\u914d\u7b26\u662f\u4e00\u79cd\u7279\u6b8a\u5b57\u7b26\uff0c\u53ef\u7528\u4e8e\u5339\u914d\u5b57\u7b26\u5e8f\u5217\u4e2d\u7684\u4e00\u4e2a\u6216\u591a\u4e2a\u5b57\u7b26\u3002\u5728 MySQL \u4e2d\uff0c\u6709\u4e24\u79cd\u901a\u914d\u7b26\uff1a\u767e\u5206\u53f7 (%) \u548c\u4e0b\u5212\u7ebf (_)\u3002<\/p>\n<p><strong>\u767e\u5206\u53f7 (%) \u901a\u914d\u7b26<\/strong><\/p>\n<p>\u767e\u5206\u53f7 (%) \u901a\u914d\u7b26\u5339\u914d\u96f6\u4e2a\u6216\u591a\u4e2a\u5b57\u7b26\u3002\u4f8b\u5982\uff1a<\/p>\n<ul>\n<li>&#8220;abc%&#8221; \u5339\u914d\u4ee5 &#8220;abc&#8221; \u5f00\u5934\u7684\u6240\u6709\u5b57\u7b26\u4e32<\/li>\n<li>&#8220;%abc&#8221; \u5339\u914d\u4ee5 &#8220;abc&#8221; \u7ed3\u5c3e\u7684\u6240\u6709\u5b57\u7b26\u4e32<\/li>\n<li>&#8220;%abc%&#8221; \u5339\u914d\u5305\u542b &#8220;abc&#8221; \u7684\u6240\u6709\u5b57\u7b26\u4e32<\/li>\n<\/ul>\n<p><strong>\u4e0b\u5212\u7ebf (_) \u901a\u914d\u7b26<\/strong><\/p>\n<p>\u4e0b\u5212\u7ebf (_) \u901a\u914d\u7b26\u5339\u914d\u4efb\u4f55\u5355\u4e2a\u5b57\u7b26\u3002\u4f8b\u5982\uff1a<\/p>\n<ul>\n<li>&#8220;a_c&#8221; \u5339\u914d &#8220;abc&#8221; \u548c &#8220;acc&#8221;<\/li>\n<li>&#8220;_bc&#8221; \u5339\u914d &#8220;dbc&#8221; \u548c &#8220;ebc&#8221;<\/li>\n<li>&#8220;%_c%&#8221; \u5339\u914d\u5305\u542b\u5355\u4e2a\u5b57\u7b26\u4e14\u4ee5 &#8220;c&#8221; \u7ed3\u5c3e\u7684\u6240\u6709\u5b57\u7b26\u4e32<\/li>\n<\/ul>\n<p><strong>\u4f7f\u7528\u901a\u914d\u7b26\u7684\u793a\u4f8b<\/strong><\/p>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e9b\u4f7f\u7528\u901a\u914d\u7b26\u7684 MySQL \u67e5\u8be2\u793a\u4f8b\uff1a<\/p>\n<ul>\n<li>SELECT * FROM table_name WHERE name LIKE &#8216;a%&#8217;; \u67e5\u627e name \u4ee5 &#8220;a&#8221; \u5f00\u5934\u7684\u6240\u6709\u8bb0\u5f55\u3002<\/li>\n<li>SELECT * FROM table_name WHERE email LIKE &#8216;%@example.com&#8217;; \u67e5\u627e email \u4ee5 &#8220;@example.com&#8221; \u7ed3\u5c3e\u7684\u6240\u6709\u8bb0\u5f55\u3002<\/li>\n<li>SELECT * FROM table_name WHERE phone_number LIKE &#8216;_999_9999&#8217;; \u67e5\u627e\u7535\u8bdd\u53f7\u7801\u4ee5 &#8220;999&#8221; \u5f00\u5934\u5e76\u5728\u4e2d\u95f4\u6709 &#8220;999&#8221; \u7684\u6240\u6709\u8bb0\u5f55\u3002<\/li>\n<\/ul>\n<p><strong>\u6ce8\u610f\u4e8b\u9879<\/strong><\/p>\n<ul>\n<li>\u901a\u914d\u7b26\u5728 MySQL \u4e2d\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002<\/li>\n<li>\u901a\u914d\u7b26\u53ea\u80fd\u7528\u5728 WHERE \u5b50\u53e5\u4e2d\u3002<\/li>\n<li>\u4f7f\u7528\u901a\u914d\u7b26\u53ef\u80fd\u4f1a\u964d\u4f4e\u67e5\u8be2\u6027\u80fd\uff0c\u5c24\u5176\u662f\u5728\u901a\u914d\u7b26\u51fa\u73b0\u5728\u67e5\u8be2\u5b57\u7b26\u4e32\u7684\u5f00\u5934\u65f6\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u901a\u914d\u7b26\u7684\u4f7f\u7528\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>mysql \u63d0\u4f9b\u4e24\u79cd\u901a\u914d\u7b26\uff1a\u767e\u5206\u53f7\u7528\u4e8e\u5339\u914d\u96f6\u4e2a\u6216\u66f4\u591a\u5b57\u7b26\uff0c\u4e0b\u5212\u7ebf\u7528\u4e8e\u5339\u914d\u5355\u4e2a\u5b57\u7b26\u3002\u4f7f\u7528\u901a\u914d\u7b26\u7684\u793a\u4f8b\u5305\u62ec\uff1a\u767e\u5206\u53f7\u901a\u914d\u7b26\uff1a&#8221;abc%&#8221; \u5339\u914d\u4ee5 &#8220;abc&#8221; \u5f00\u5934\u7684\u6240\u6709\u5b57\u7b26\u4e32\u3002&#8221;%abc&#8221; \u5339\u914d\u4ee5 &#8220;abc&#8221; \u7ed3\u5c3e\u7684\u6240\u6709\u5b57\u7b26\u4e32\u3002&#8221;%abc%&#8221; \u5339\u914d\u5305\u542b &#8220;abc&#8221; \u7684\u6240\u6709\u5b57\u7b26\u4e32\u3002\u4e0b\u5212\u7ebf\u901a\u914d\u7b26\uff1a&#8221;a_c&#8221; \u5339\u914d &#8220;abc&#8221; \u548c &#8220;acc&#8221;\u3002&#8221;_bc&#8221; \u5339\u914d &#8220;dbc&#8221; \u548c &#8220;ebc&#8221;\u3002&#8221;%_c%&#8221; \u5339\u914d\u5305\u542b\u5355\u4e2a\u5b57\u7b26\u4e14\u4ee5 &#8220;c&#8221; \u7ed3\u5c3e\u7684\u6240\u6709\u5b57\u7b26\u4e32\u3002 MySQL \u901a\u914d\u7b26\u7684\u4f7f\u7528 \u4ec0\u4e48\u662f\u901a\u914d\u7b26\uff1f \u901a\u914d\u7b26\u662f\u4e00\u79cd\u7279\u6b8a\u5b57\u7b26\uff0c\u53ef\u7528\u4e8e\u5339\u914d\u5b57\u7b26\u5e8f\u5217\u4e2d\u7684\u4e00\u4e2a\u6216\u591a\u4e2a\u5b57\u7b26\u3002\u5728 MySQL \u4e2d\uff0c\u6709\u4e24\u79cd\u901a\u914d\u7b26\uff1a\u767e\u5206\u53f7 (%) \u548c\u4e0b\u5212\u7ebf (_)\u3002 \u767e\u5206\u53f7 (%) \u901a\u914d\u7b26 \u767e\u5206\u53f7 (%) \u901a\u914d\u7b26\u5339\u914d\u96f6\u4e2a\u6216\u591a\u4e2a\u5b57\u7b26\u3002\u4f8b\u5982\uff1a &#8220;abc%&#8221; \u5339\u914d\u4ee5 &#8220;abc&#8221; \u5f00\u5934\u7684\u6240\u6709\u5b57\u7b26\u4e32 &#8220;%abc&#8221; \u5339\u914d\u4ee5 &#8220;abc&#8221; \u7ed3\u5c3e\u7684\u6240\u6709\u5b57\u7b26\u4e32 &#8220;%abc%&#8221; \u5339\u914d\u5305\u542b &#8220;abc&#8221; \u7684\u6240\u6709\u5b57\u7b26\u4e32 \u4e0b\u5212\u7ebf (_) \u901a\u914d\u7b26 \u4e0b\u5212\u7ebf (_) \u901a\u914d\u7b26\u5339\u914d\u4efb\u4f55\u5355\u4e2a\u5b57\u7b26\u3002\u4f8b\u5982\uff1a [&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-6376","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6376","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=6376"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6376\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6376"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6376"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6376"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}