<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Zing's Blog RSS Feed]]></title><description><![CDATA[Zing's Blog.]]></description><link>https://blog.zingimmick.com</link><generator>GatsbyJS</generator><lastBuildDate>Thu, 22 Oct 2026 01:32:20 GMT</lastBuildDate><item><title><![CDATA[SQL LIKE 如何查询包含特殊字符的字符串]]></title><description><![CDATA[根据MySQL手册： MySQL uses C escape syntax in strings (for example,  to represent the newline character). If you want a 
string to contain a…]]></description><link>https://blog.zingimmick.com/sql-like-string-contains-special-chars/</link><guid isPermaLink="false">https://blog.zingimmick.com/sql-like-string-contains-special-chars/</guid><pubDate>Wed, 12 Apr 2023 13:37:50 GMT</pubDate><content:encoded>&lt;p&gt;根据&lt;a href=&quot;https://dev.mysql.com/doc/refman/8.0/en/string-comparison-functions.html#operator_like&quot;&gt;MySQL手册&lt;/a&gt;：&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;MySQL uses C escape syntax in strings (for example, &lt;code class=&quot;language-text&quot;&gt;\n&lt;/code&gt; to represent the newline character). If you want a &lt;code class=&quot;language-text&quot;&gt;LIKE&lt;/code&gt;
string to contain a literal &lt;code class=&quot;language-text&quot;&gt;\ &lt;/code&gt;, you must double it. (Unless the &lt;code class=&quot;language-text&quot;&gt;NO_BACKSLASH_ESCAPES&lt;/code&gt; SQL mode is enabled, in which
case no escape character is used.) For example, to search for &lt;code class=&quot;language-text&quot;&gt;\n&lt;/code&gt;, specify it as &lt;code class=&quot;language-text&quot;&gt;\\n&lt;/code&gt;. To search for &lt;code class=&quot;language-text&quot;&gt;\ &lt;/code&gt;, specify
it as &lt;code class=&quot;language-text&quot;&gt;\\\\&lt;/code&gt;; this is because the backslashes are stripped once by the parser and again when the pattern match is
made, leaving a single backslash to be matched against.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;\%&lt;/code&gt;匹配一个&lt;code class=&quot;language-text&quot;&gt;%&lt;/code&gt;字符。&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;mysql&quot;&gt;&lt;pre class=&quot;language-mysql&quot;&gt;&lt;code class=&quot;language-mysql&quot;&gt;SELECT &amp;#39;David!&amp;#39; LIKE &amp;#39;David\%&amp;#39;; # 0
SELECT &amp;#39;David%&amp;#39; LIKE &amp;#39;David\%&amp;#39;; # 1&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;\_&lt;/code&gt;匹配一个&lt;code class=&quot;language-text&quot;&gt;_&lt;/code&gt;字符。&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;mysql&quot;&gt;&lt;pre class=&quot;language-mysql&quot;&gt;&lt;code class=&quot;language-mysql&quot;&gt;SELECT &amp;#39;David!&amp;#39; LIKE &amp;#39;David\_&amp;#39;; # 0
SELECT &amp;#39;David_&amp;#39; LIKE &amp;#39;David\_&amp;#39;; # 1&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;p&gt;若要指定其他转义字符，请使用&lt;code class=&quot;language-text&quot;&gt;ESCAPE&lt;/code&gt;子句：&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;mysql&quot;&gt;&lt;pre class=&quot;language-mysql&quot;&gt;&lt;code class=&quot;language-mysql&quot;&gt;SELECT &amp;#39;David_&amp;#39; LIKE &amp;#39;David|_&amp;#39; ESCAPE &amp;#39;|&amp;#39;; # 1&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;blockquote&gt;
&lt;p&gt;更新于&lt;code class=&quot;language-text&quot;&gt;2023-04-13 21:47:50&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;部分数据库（如&lt;code class=&quot;language-text&quot;&gt;SQLite&lt;/code&gt;、&lt;code class=&quot;language-text&quot;&gt;PostgreSQL&lt;/code&gt;、&lt;code class=&quot;language-text&quot;&gt;SQL Server&lt;/code&gt;）不支持默认转义字符，必须使用&lt;code class=&quot;language-text&quot;&gt;ESCAPE&lt;/code&gt;子句指定转义字符&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;更新于&lt;code class=&quot;language-text&quot;&gt;2023-04-14 21:42:34&lt;/code&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;code class=&quot;language-text&quot;&gt;PHP&lt;/code&gt; 转义代码&lt;/p&gt;
&lt;div class=&quot;gatsby-highlight&quot; data-language=&quot;php&quot;&gt;&lt;pre class=&quot;language-php&quot;&gt;&lt;code class=&quot;language-php&quot;&gt;&lt;span class=&quot;token function&quot;&gt;str_replace&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string single-quoted-string&quot;&gt;&apos;\\&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string single-quoted-string&quot;&gt;&apos;_&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string single-quoted-string&quot;&gt;&apos;%&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;[&lt;/span&gt;&lt;span class=&quot;token string single-quoted-string&quot;&gt;&apos;\\\\&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string single-quoted-string&quot;&gt;&apos;\\_&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token string single-quoted-string&quot;&gt;&apos;\\%&apos;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;]&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;$string&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;</content:encoded></item><item><title><![CDATA[Hello World]]></title><description><![CDATA[第一篇博客，好激动！ 顺便试试评论功能是不是正常的。]]></description><link>https://blog.zingimmick.com/hello-world/</link><guid isPermaLink="false">https://blog.zingimmick.com/hello-world/</guid><pubDate>Fri, 25 Feb 2022 04:37:50 GMT</pubDate><content:encoded>&lt;p&gt;第一篇博客，好激动！&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;顺便试试评论功能是不是正常的。&lt;/p&gt;
&lt;/blockquote&gt;</content:encoded></item></channel></rss>